# ConvNeXt-Based Fine-Grained Image Classification and Bilinear Attention Mechanism Model
## 3 Proposed Algorithm
### Bilinear Attention Mechanism  
In addition to embedding an attention mechanism in ConvNeXt-Tiny for the weight allocation of fine-grained features, in this paper, the convolutional block attention module (CBAM) mechanism [23] is further improved, and a new attention mechanism is proposed to improve the accuracy of ConvNeXt in performing fine-grained classification tasks to the fullest extent. This section introduces the improved CBAM in detail. Based on the idea of a bilinear CNN, in this paper, the CBAM mechanism is improved with the idea of bilinearity; a bilinear CBAM (BCBAM) is proposed. Additionally, the feature information of channels and spatial dimension are integrated to improve the channel attention module (CAM) in the CBAM. To improve the algorithm in this paper, considering the bilinearity of the BCNN, the original maximum pooling and average pooling paralleling is retained to maintain the feature information of the original map to the fullest extent. Then, the output result concatenation is performed based on the channels. The full connection layer in the original structure is changed to a \(1\times 1\) convolutional layer,  
Figure 5: Structure chart of EBA (based on each ConvNeXt block). Figure 6: Structure chart of SBA (based on each type of block). and layer normalization is utilized for batch data processing. Since ConvNeXt uses the same Gaussian error linear unit (_GeLUI_) activation function as the Swin transformer, the rectified linear unit (ReLU) activation function in the CAM is replaced with a _GeLUI_ with random regularity. Its structure is shown in Figure 7:  
The processing of input data by the network mentioned above is shown in Formula (1):  
\[ \begin{split}\mathbf{F_{a1}}&=\sigma(Conv(GeLU(LN(Conv( Concat(Aggpool(\mathbf{F}),Maxpool(\mathbf{F}))))))\\ &=\sigma(\mathbf{W_{1}}(GeLU(LN(\mathbf{W_{0}}(Concat(\mathbf{F_{avg}},\mathbf{F_{ max}}^{\mathbf{c}}))))))\end{split}  \tag{1}\]  
where \(\mathbf{F_{a1}}\) represents the feature map output by the CAM mechanism; \(Conv\) is the convolution; and \(\sigma\) and _GeLUI_ are activation functions. After the _GeLUI_ activation function is applied, \(\mathbf{F}\in\mathbb{R}^{(\text{B,2C}/\text{v,W,H})}\), and after the sigmoid activation function is applied, \(\mathbf{F}\in\mathbb{R}^{(\text{B,C,W,H})}\); Avgpool and Maxpool are the average pooling and maximum pooling, respectively. Next, bilinearity is brought into the spatial attention module (SAM). [PERSON] et al. [24] proposed a spatial attention method that uses \(1\times 1\) and \(3\times 3\) convolutions to obtain more abundant and diverse feature information. In this paper, this method is improved on this basis. First, \(1\times 1\) and \(3\times 3\) convolution operations are performed for the input feature map, respectively. After obtaining spatial features of different scales, layer normalization and _GeLUI_ activation function mappings are carried out for the two features. Then, \(1\times 1\) convolution is used to reduce the dimensions of the features to single channels. These two single-channel features are multiplied to obtain the multiscale spatial attention features, which are then multiplied by the feature map with channel attention weight to obtain a feature map with both channel weight features and spatial features. Batch processing is performed for the data using layer normalization for two reasons. The first reason is to utilize the research result of ConvNeXt. Since batch processing is performed with layer normalization in transformer models, in this paper, the attention information is batched using layer normalization, which matches the data processing of ConvNeXt more closely. Second, batch normalization is always employed in CNNs. It is associated with the batch size used in training. The larger the batch size is, the better the effect. Nevertheless, the batch size is limited by the hardware but unrelated to the layer normalization. In terms of selecting the size of the convolution kernel, \(1\times 1\) and \(3\times 3\) convolutions are used.