# A Serial Attention Frame for Multi-Label Waste Bottle Classification
## 3 The Proposed SAF  
The proposed 104-layer SAF contains the following three parts: a residual learning block (RB), a mixed attention block (_MAB_), and a self-attention block (SAB), as shown in Figure 1, where the images collected from the cameras are not very clear, due to the illumination conditions of the sorting machine. More detailed information is illustrated in Figure 1.  
RB: The RB uses a 101-layer ResNet [8] to pretrain SAF to extract more detailed information, where its parameters are referred to in [8]. Let us denote a bottle image with a size of 448 \(\times\) 448 as the input of RB. The RB contains 1-layer Conv1 + BN + ReLU, Layer1, Layer2, Layer3, and Layer4. Specifically, one-layer Conv1 + BN + ReLU denotes the combination of a convolutional layer, batch normalization (BN) [32], and rectified linear unit (ReLU) [33], where its parameters are an input channel number of 3, kernel size of 7 \(\times\) 7, and output channel number of 64. Moreover, it acts as a one-layer max-pooling layer, which acts as a 9-layer Layer1. Layer1 contains three bottlenecks, and each bottleneck is made up of Conv + BN + ReLU, Conv + BN, and a single ReLU; their parameters are introduced Ref. [8]. The output of Layer1 is the input of Layer2. Layer2 includes four bottlenecks and it connects Layer3. Layer3 is composed of twenty-three bottlenecks and it connects Layer4. Layer4 consists of three bottlenecks and it connects \(MAB\). The process can be represented as Equation (1), as follows:  
\[O_{R}=R(I)=L4(L3(L2(L1(MP(CBR(I)))))) \tag{1}\]  
Moreover, \(R\) expresses a function of ResNet, and is a function of the combination of a convolutional layer, BN, ReLU, and max-pooling layer, respectively. In addition, \(L1\), \(L2\), \(L3\), and \(L4\) denote functions of Layer1, Layer2, Layer3, and Layer4, respectively. Further, \(O_{R}\) denotes the output of ResNet as the input of \(MAB\). Figure 1: Network architecture of SAF. The residual learning block (RB) is pretrained to learn more context features. The mixed attention block (\(MAB\)) can extract salient category information via the simultaneous use of channel attention and spatial attention. The self-attention block (SAB) constructs a classifier with attention to improve performance. _MAB:__MAB_ uses one-layer channel attention [9] and one-layer spatial attention [9] to extract more salient category information. Specifically, mixed attention can be formulated as Equation (2), as follows:  
\[ \begin{array}{ll}O_{MAB}&=MAB(O_{R})\\ &=S(C(O_{R}))\end{array}  \tag{2}\]  
where _MAB_ is the function of _MAB_, which is composed of the functions (_C_ and _S_) of channel attention and spatial attention. The channel attention block [9] aims to find out which channels deserve attention, and its structure is shown in Figure 2a. It consists of a max-pooling operation, an average pooling operation, a multi-layer perceptron (MLP), and a sigmoid operation. Specifically, it firstly exerts average-pooling and max-pooling operations to create a map with the size 14 \(\times\) 14 \(\times\) 2048, and then a parameter-shared MLP aggregates the obtained feature vectors. More detailed information can be found in Equation (3), as follows:  
\[ \begin{array}{ll}O_{c}&=C(O_{R})\times O_{R}\\ &=f_{sigmoid}(f_{mlp}(f_{avg}(x))+f_{mlp}(f_{\max}(x)))\times O_{R}\end{array}  \tag{3}\]  
where \(\times\) is the multiplication operation. Let \(f_{avg}\) and \(f_{max}\) define the average-pooling operation and max-pooling operation, respectively. \(f_{sigmoid}\) is used to express the sigmoid function and \(f_{mlp}\) is a function of MLP, which is shown in Figure 3. \(O_{c}\) denotes the output of channel attention, which acts as the spatial attention block. Figure 2: Network architecture of channel attention block (**a**) and spatial attention block (**b**). The channel attention block learns which channels of feature maps are important; the spatial attention block finds out “where” feature maps are vital. Together, _MAB_ can aggregate more effective information regarding categories.