# Target State Classification by Attention-Based Branch Expansion Network
## 3 Proposed Methods
### Methods
#### 3.2.2 ABE Networks and Attention Module
So, we adopt the global average pool (GAP) and the global max pool (GMP) simultaneously to shrink the input feature \(F\) from \(H\times W\) and obtain two channel-wise descriptors \(F^{c}_{avg}\) and \(F^{c}_{max}\). Then, a multi-layer perception (MLP) capable of learning a nonlinear interaction between channels is used to infer the channel attention map from \(F^{c}_{avg}\) and \(F^{c}_{max}\). Since the two pools play the same role thus have the same status, the weights of MLP are shared with both of them. \[ \begin{split} M_{c}&=MLP(GAP(F))+MLP(GMP(F))\\ &=W_{1}(W_{0}(F^{c}_{avg}))+W_{1}(W_{0}(F^{c}_{max}))\end{split}  \tag{1}\]  
where GAP and GMP denote the pooling operations, and \(W_{1}\) and \(W_{0}\) are learnable parameters of the \(MLP\) module that are shared with both \(F^{c}_{avg}\) and \(F^{c}_{max}\). Figure 5: Schematic for the connection between the attention module and a multi-branch block. Figure 6: A plug-and-play dual-attention module with parallel residual connection to refine the feature extract by the multi-branch blocks mentioned in Figure 3.  
The spatial descriptor is also generated from the average pool and max pool operations. Different from the channel-wise statistics, the spatial attention focuses on \"where\" so that the squeeze input from \(C\) to 1 to compute the spatial statistics across the channel dimension is similar to the practice in [42]. Another difference is that the two are concatenated together to generate the spatial descriptor because they both describe features on a plane dimension. A standard convolution layer with the filter size of \(7\times 7\) is adopted to encode the spatial descriptor \([F_{avg}^{s};F_{max}]\) to obtain attention map \(M_{s}\) as follows:  
\[ \begin{split} M_{s}&=f^{7\times 7}([AvgPool(F), MaxPool(F)])\\ &=f^{7\times 7}([F_{avg}^{s};F_{max}^{s}])\end{split}  \tag{2}\]  
The parallel concatenated dual-attention map \(M_{F}\) and the refined feature \(F_{A}\) is computed as follows:  
\[M_{F}=\sigma(M_{c}+M_{s}) \tag{3}\]  
where \(\sigma\) is a sigmoid activation function. Equation (3) represents the parallel connection of the two attention maps. Different from the sequential fusion of the two attention maps in CBAM [19], we conduct multiple experiments and prove that the parallel connection shown in Figure 6 is more friendly to our datasets. \[F_{A}=F+F\otimes M_{F} \tag{4}\]  
where \(\otimes\) denotes element-wise multiplication. Equation (4) gives a residual connection scheme along with the parallel attention following the practice in [38; 39] to facilitate the gradient flow and avoid model overfitting. We apply this plug-and-play dual attention module in the aforementioned 4 structures as illustrated in Figure 4. The attention module is plugged at the end of each multi-branch block, which has the same number of depths of the block. Since the blocks followed by an attention module each has a different arrangement in the 4 structures, the attention module also is used at different locations; therefore, the influence of attention on the model is different. Even if an XC network of a certain depth and width proves to be the best performer, it is not certain whether an ABE network based on that structure is the best performer. So, we still apply the attention module to each of the four structures in the form of convolutional blocks, and conduct detailed experimental comparisons in Section 4.3.