# A Lithology Recognition Network Based on Attention and Feature Brownian Distance Covariance
## 2 Methodology
### Improvements to the CBAM  
To enhance the classification accuracy of the model, mitigate the extraction of irrelevant features, and bolster the network's capacity to discern rock features, we propose an enhanced Convolutional Block Attention Module (CBAM) attention mechanism. The conventional CBAM attention mechanism employs two modules, namely channel and spatial, to jointly regulate feature mapping. In the original Channel Attention Module (CAM) [20], input feature maps undergo extraction through two parallel branches involving global maximum pooling and global average pooling. These processes compress the feature maps into a \(1\times 1\times\) C format. Subsequently, the number of channels is compressed to the original \(1\times 1\times\) C/p through a multi-perceptual layer mechanism. The channels are then expanded back to their original count, and the outputs from the two parallel branches undergo summation, ultimately yielding the CAM output through the Sigmoid activation function. Finally, this result is multiplied with the input feature map. Within the shared neural network, the dimensionality reduction multilayer perceptron (MLP) operates as follows: firstly, the \(1\times 1\times\) C feature map undergoes dimensionality reduction to a \(1\times 1\times\) C/p feature map, and subsequently, it is upgraded to a \(1\times 1\times\) C size. While this dimensionality reduction operation effectively reduces computational load and model parameters, it introduces a significant loss of detail information from the feature map. This loss interferes with the generation of channel attention feature weights, rendering the mechanism incapable of attenuating interference from background information. For the intricate lithology recognition task, the nuances of rocks, including their shape, color, and texture, are intricately linked to their lithological composition. Thus, the extraction of detailed features holds paramount importance in lithology recognition. The ascending MLP demonstrates superior capability in retaining and extracting intricate image  
Figure 2: ResNet18 backbone network. details, thereby augmenting classification accuracy by mapping low-dimensional features to high-dimensional space. To bolster the extraction of detailed features from rock surface imagery, this study proposes an enhancement to the CBAM channel attention module. This enhancement entails transforming the original CBAM's reduced-dimensional MLP into an ascending multilayer perceptron structure. The structure of the enhanced CBAM is illustrated in Figure 3.  
Initially, the feature map F, characterized by dimensions H \(\times\) W \(\times\) C, serves as the input. As the feature map traverses the improved channel attention module, the ascending multilayer perceptron operation transforms the 1 \(\times\) 1 \(\times\) C feature map into 1 \(\times\) 1 \(\times\) pC, followed by a reduction to the original 1 \(\times\) 1 \(\times\) C feature map through a descending operation. This dimensionality-raising multilayer perceptron adepdly preserves and extracts detailed image information by mapping low-dimensional features to high-dimensional space, thereby enhancing the accuracy of lithology recognition. Subsequently, the output feature map from the channel attention module becomes the input for the Spatial Attention Module (SAM). Through maximum pooling and mean pooling operations on the channel, the input feature map undergoes extraction of global and local information in the spatial dimensions, yielding two two-dimensional feature maps: the mean-pooled feature and the maximally pooled feature. These features are concatenated, followed by transformation into a 1-channel feature map through convolution operations. Application of the Sigmoid activation function produces the final output result of SAM. Finally, this result undergoes element-wise multiplication with the input feature map, extracting crucial image feature information and yielding the output F' of the improved CBAM. The dimension of F' aligns with that of the input feature map.