## 2 Materials and Methods  
### Principle of AP-CNN  
The principles of the AP-CNN [29; 30] and the fine-grained image classification algorithm [28] used in this paper are shown in Figure 1. Figure 1a illustrates the dual-path algorithm structure, Figure 1b presents the attention pyramid, and Figure 1c illustrates the region of interest (ROI) pyramid. The blue border represents the feature map, and the orange border represents the channel/space attention. First, the AP-CNN network takes an image as input and generates a feature pyramid network (FPN) and an attention pyramid [31] to enhance representations by improving on the CNN to obtain a dual-path algorithm structure, including a top-down feature path and a bottom-up attention path. The FPN [29] is used on the top-down path to extract features at different scales. Then, an additional attention hierarchy is introduced to further enhance the structure, including a spatial attention pyramid \(\left\{A_{n}^{(s)},A_{n+1}^{(s)},\dots,A_{n+N-1}^{(s)}\right\}\) for locating discriminative regions at different scales, and a channel attention path \(\left\{A_{n}^{(c)},A_{n+1}^{(c)},\dots,A_{n+N-1}^{(c)}\right\}\) for adding channel correlations in another bottom-up path and transferring local information from the lower pyramid level to the higher pyramid level. For the spatial attention pyramid, each building block takes the feature map of the corresponding layer \(F_{k}\) as input and generates the spatial attention mask \(A_{k}^{(s)}\). The feature  
Figure 1: Structure of the AP-CNN for OAM mode recognition. (**a**) dual-path algorithm structure, (**b**) attention pyramid, (**c**) ROI pyramid. map \(F_{k}\) first passes through a 3 \(\times\) 3 deconvolution layer with only one output channel to compress the spatial information. Each element of the spatial attention mask \(A_{k}^{(s)}\) is normalized to be in the range of 0 to 1 using the sigmoid function, expressed as:  
\[A_{k}^{(s)}=\sigma(v_{c}*F_{k}) \tag{1}\]  
where \(\sigma\) denotes the sigmoid function, \(v_{c}\) denotes the convolution kernel, and \(*\) denotes the deconvolution with the fixed convolution kernel. For the channel attention path, the channel attention can be obtained by passing the global average pooling layer and two fully connected layers in the corresponding feature layer of the feature pyramid. The channel attention mask formula is given by,  
\[A_{k}^{(c)}=\sigma(W_{2}\cdot\text{ReLu}(W_{1}\cdot\text{GAP}(F_{k}))) \tag{2}\]  
where GAP represents the global average pooling layer, \(W_{1}\) and \(W_{2}\) represent the weight matrices of the two fully connected layers. The learned attention is used to weight the feature \(F_{k}\) to obtain \(F_{k}^{\prime}\), which is used for classification as follows,  
\[F_{k}^{\prime}=F_{k}\cdot(A_{k}^{(s)}\oplus A_{k}^{(c)}) \tag{3}\]  
where \(\oplus\) represents the broadcasting addition operation on semantics. Spatial attention tensor and channel attention tensor have different shapes, and the plus operator must be of broadcast type. In the second step, after obtaining the spatial attention pyramid, the ROI pyramid continues to be generated by the region suggestion generator of adaptive non maximum suppression (NMS) [32] in a weakly supervised manner. The purpose of the Region Proposal Network (RPN) [33] is to select a frame that may contain a target. In essence, it is based on the unclassified target detector of the sliding window; it inputs an image of any scale and obtains a candidate frame with a predetermined size and scale. The general RPN network is mostly applied to the single- or multi-scale convolution network feature map. Multiple sizes and aspect ratios are preset to locate objects of different sizes and shapes. On the basis of RPN theory, AP-CNN uses a spatial attention mask as an anchor score and uses weak supervision to select the distinguishing area.