# Object Detection Algorithm Based on Multiheaded Attention
## 3 Methods
### MANet Model
#### 3.2.3 Fusion Attention  
In the execution of the task of target detection, it can be intuitively understood that in the CNN, the shallow feature maps tend to be small. Therefore, they are usually used for the detection of small objects, and the feature layers that are closer to the top layer are often very sensitive. Therefore, large feature maps are often used for the detection of large objects. In recent years, many jobs have enhanced the range of receptive fields by combining the feature information from feature maps obtained at different scales. For example, in 2017, [PERSON] et al. proposed the DSSD [20], the first constructed SSD based on ResNet-101. The authors introduced a deconvolution layer as the code-decoder to convey contextual information, thus achieving excellent results in small-object detection. In essence, the feature information of different receptive fields was fused by deconvolution. Therefore, the relationship among the feature maps of receptive fields with different sizes has an important influence on the target detection accuracy. The relationship among the feature maps of receptive fields with different sizes is intended to capture the dependencies among the different feature maps associated with the  
Figure 1: Networks of (**a**) Single-shot Multibox Detector (SSD) and (**b**) Multiheaded Attention Net (MANet). The blue modules are the layers added in the SSD framework are referred to as the SSD layers. In (**b**), the green layers are the MANet layers (where conv1_x, conv2_x, conv3_x, conv4_x, conv5_x, are the convolution feature layers at different scales).  
different receptive fields and enhance their respective feature expression capabilities. Therefore, to obtain the feature information from the various receptive field maps with different sizes, this study introduces a fusion attention module that mainly uses the correlation between different scale feature maps to enhance the expression of each feature. We describe below the working process of the fusion attention module.  
As shown in Figure 2, the feature map \(X\in R^{\mathbb{C}\times H\times W}\) is first input to the convolution layer with the batch normalization and the ReLU layers, generates two new features \(F\) and \(G\)--where \(C\times H\times W\) represent the channel, height, width, \(\{F,G\}\in R^{\mathbb{C}\times H\times W}\)--and then reshapes them to \(R^{\mathbb{C}\times N}\), where \(N=H\times W\) denotes the number of features. The features \(F\) and \(G\) are then transposed and multiplied, and are then normalized by the softmax operation to obtain the attention map of the scale feature \(O\in R^{N\times N}\):  
\[f_{ji}=\frac{\textit{exp}\left(F_{i}\cdot G_{j}\right)}{\sum_{i=1}^{N}\textit {exp}\left(F_{i}\cdot G_{j}\right)} \tag{1}\]  
At the same time, another feature map \(W\in R^{\mathbb{C}\times H\times W}\) is constructed, and the feature \(U\) is sent to the convolution layer with the batch normalization and ReLU layers to generate a new feature \(Y\in R^{\mathbb{C}\times H\times W}\), shape it into \(R^{\mathbb{C}\times N}\), multiply the attention map \(O\) by the transpose of the feature \(Y\), and reshape the result to \(R^{\mathbb{C}\times H\times W}\). Finally, the output is multiplied by a scale parameter \(\alpha\) to obtain \(V_{j}\) and a sum operation is executed with the feature \(X\) to obtain the final output \(T\in R^{\mathbb{C}\times H\times W}\) as follows,  
\[\begin{split} V_{j}&=\ \alpha\sum_{i=1}^{N}\left(f_{ji}Y_{i} \right)\\ T_{j}&=\ \alpha\sum_{i=1}^{N}\left(f_{ji}Y_{i} \right)\ +\ X_{J}\end{split} \tag{2}\]  
where \(\alpha\) is initialized to zero and is gradually assigned to additional weights. It can be inferred from the above formula that the final feature \(T\) is the result of the fusion of the two different feature maps.  
Thus, the fusion attention module has the ability to fuse different features and selectively aggregate features. A mutual gain between the features is achieved and is more conducive to target detection.