# ConvNeXt-Based Fine-Grained Image Classification and Bilinear Attention Mechanism Model
## 3 Proposed Algorithm
### ConvNeXt Model Embedded with Attention Mechanism  
In the ConvNeXt network structure, there are four types of blocks depending on the number of channels in the output feature map. Each type of block cycles for a different number of times: the first type cycles 3 times, outputting a 96-dimensional feature map; the second type cycles 3 times, outputting a 192-dimensional feature map; the third type cycles 3 times, outputting a 384-dimensional feature map; and the fourth type cycles 3 times, outputting a 768-dimensional feature map. Each time the feature map undergoes a downsampling operation before a block, the final output size (W, H) of the block becomes half that of the original, and the output dimension is doubled under the action of convolution. In this case, it seems very important to add weight values to channels.  
In performing fine-grained classification tasks, the accurate localization of targets is necessary for feature extraction. So that the network can learn specific target features during the process of training, every block attention (EBA) and sever block attention (SBA) are proposed based on the embedding position.  
Integrating the attention mechanism with each block in the ConvNeXt-Tiny network can enable the attention mechanism to be embedded in the internal cycle of each type of block. This is called EBA. When the attention weight is applied to the feature map with inverted residuals, attention parameters are cyclically trained in each block. Then each block cycling object forms a feature map with attention weight, which realizes the repeated training of attention parameters. For the specific structure of the modified ConvNeXt Block, see Figure 5:  
Figure 4: Structure chart of ConvNeXt Block.  
Figure 3: Network structure chart of ConvNeXt-Tiny.  
The integration of the attention mechanism with the block after ConvNeXt-Tiny cycling is called SBA. The attention mechanism does not interfere with the block cycling process. Instead, it acts on the feature map after each type of block cycling comes to an end so that the training of attention weight depends on the whole cycled feature map rather than a single block. This can reduce the number of attention parameter trainings. In addition, to enable the network to solve the problems of degradation, exploding gradient, and vanishing gradient of the deep network, the downsampled feature map is added to the output of the attention module in the form of a residual shortcut based on the channel. For the specific structure, see Figure 6.  
Due to the residual structure, when the attention mechanism is combined through SBA, the residual connection outside the attention of the third type of block is cancelled (as shown in Figure 6). This is because the third type of block in all versions of ConvNeXt cycles the most, such as nine cycles in the Tiny version. If an external residual connection is added, a large number of unprocessed and shallow semantic information is integrated into the attention feature map, weakening the overall feature extraction ability and learning ability of the network.