# SAR Image Aircraft Target Recognition Based on Improved YOLOv5
## 3 Materials and Methods  
### Design of the Multiscale Feature Adaptive Fusion Module  
In the backbone of YOLOv5, when the resolution of the input image is 640 \(\times\) 640, feature maps (C1, C2, C3, C4, C5) of different scales are extracted through multiple instances of convolutional downsampling. The resolutions of the feature maps C1, C2, C3, C4, and C5 are 320 \(\times\) 320, 160 \(\times\) 160, 80 \(\times\) 80, 40 \(\times\) 40, and 20 \(\times\) 20, respectively, corresponding to 2-, 4-, -8-, 16-, and 32-fold downsampling. Shallow feature maps have more textural features of the target, which contain richly detailed information. Shallow feature maps are suitable for the detection of small targets. Deep feature maps have a larger receptive field, which can extract richer semantic information. Deep feature maps are suitable for the detection of large targets. The algorithm uses feature maps C3, C4, and C5 to predict multiscale targets (small, medium, and large, respectively). Feature maps C3, C4, and C5 are sent to the FPN and PAN for fusion of the multiscale features to obtain the feature maps P3, P4, and P5. FPN and PAN fuse feature maps with different scales with an equal weight, although, in fact, feature maps with different scales make different contributions to target recognition. Simple fusion weakens the performance of the network in terms of recognition. In response to these problems, we designed an MFAF module based on the ASHF [28] module. Feature maps (P3, P4, P5) were the input of the MFAF module, which can assign different weights to the feature maps at each scale, adaptively adjust the contribution of shallow features and deep features, and strengthen the feature information required for the detection of targets of different sizes. Figure 1 shows the structure of the MFAF module. Figure 1: Structure of the MFAF module. The feature maps P3, P4, and P5 of YOLOv5 have different resolutions and the same number of channels. In order to fuse P3, P4, and P5, they need to be unified into feature maps with the same resolution. The feature map of layer \(l\) (\(l\in\{3,4,5\}\)) is represented by \(X_{l}\). For the feature fusion of layer \(l\), we resize the features at the other layer \(n\) (\(n\
eq l\)) to the same shape as that of \(X_{l}\) by adopting upsampling or downsampling strategies. The resized feature map is represented by \(X_{n\to l}\), whose size is \(C\times H\times W\). We integrate the squeeze-and-excitation (SE) [29] mechanism into the ASFF framework. Firstly, the resized feature maps \(X_{3\to lj}\), \(X_{4\to l}\), and \(X_{5\to l}\) are concatenated into the channel dimension to obtain \(X\) with size \(3C\times H\times W\). Each channel of \(X\) is subjected to global average pooling to obtain \(Z\) with size \(3C\times H\times W\), which is expressed as follows:  
\[Z_{c}=F_{sq}(X_{c})=\frac{1}{H\times W}{\sum}_{i=1}^{H}{\sum}_{j=1}^{W}X_{c}(i,j) \tag{1}\]  
where \(X_{c}\) represents the feature map of the \(c\)th channel of \(X\); \(Z_{c}\) represents the global feature of the \(c\)th channel of \(X\); and \(F_{sq}\) represents the squeeze operation. Secondly, the non-linear relationship between each channel is learned through two FC operations and the ReLU activation function, then the sigmoid activation function is used to generate the weight of each channel to obtain \(S\). The formula is expressed as follows:  
\[S=F_{ex}(Z,W)=\sigma[W_{2}\delta(W_{1}Z)] \tag{2}\]  
where \(F_{ex}\) represents the excitation operation; \(W_{1}\) and \(W_{2}\) represent the two FC operations; \(W_{1}\) is used to compresses the features of the channels' dimensions and capture the relationship between the channels; \(W_{2}\) is used to restore the channels' dimensions; \(\delta\) represents the ReLU activation function; \(\sigma\) represents the sigmoid activation function; and \(S\) represents the weight matrix.