## 3 Method
### Triplet Attention Mechanism  
In this study, we aim to classify images of various unpretreated rocks taken under natural conditions. Although each rock image in the dataset contains only one rock type, the features of rock morphology, texture, and color may vary slightly at different spatial positions within the same image, resulting in an uneven distribution of rock features in rock images. The SE attention module of EfficientNet only pays attention to the importance of different rock feature channels and is unable to calculate the importance of rock features at different spatial positions, thereby limiting the accuracy of the rock image classification model based on EfficientNet. To address this, we introduce a triplet attention module that can capture both spatial and channel attention information to replace the SE module in EfficientNet, thus proposing an improved EfficientNet model--Triplet-EfficientNet. As shown in Figure 7, the triplet attention module not only assigns weights to different feature channels of the input rock feature tensor, but also assigns weights to different spatial positions on each channel. The output rock feature tensor in Figure 7 not only has colored borders representing different weights for each feature channel, but also different colors at different positions on each channel. The parts of each feature channel that are closer to blue represent spatial features that have less impact on classification accuracy and will be assigned smaller weights by the module, while the parts that are closer to red represent more effective rock spatial features, and thus receive more attention from the module and are assigned larger weights. Therefore, by incorporating a triple attention module in the classification model, we can effectively address the issue of imbalanced spatial feature distribution in rock images, significantly improve the model's capability to extract effective features, and ultimately enhance its overall accuracy. The triplet attention module consists of three parallel branches, as shown in Figure 7, which takes in an input rock feature tensor and outputs a refined tensor of the same shape. Given an input rock feature tensor \(X\in\mathbb{R}^{\text{C}\times\text{H}\times\text{W}}\), the module first passes it to each attention branch respectively to capture the cross-dimension interaction information among channel dimension C, spatial dimension H, and W.  
In the first branch, the triplet attention module builds the interactions between the spatial height (H) dimension and the channel (C) dimension. To achieve so, the input \(X\) is first rotated 90 degrees counterclockwise along the H axis to obtain a rotated tensor \(X_{H}\in\mathbb{R}^{\text{W}\times\text{H}\times\text{C}}\). Then \(X_{H}\) would be squeezed into a two-dimensional tensor of size 1 \(\times\) H \(\times\) C through a C-Pool layer, a convolutional layer of kernel size 7 \(\times\) 7, and a batch normalization layer. Next, the tensor of size 1 \(\times\) H \(\times\) C passes through the Sigmoid activation function to generate the resultant attention weights. Following this, the generated attention weights are applied to \(X_{H}\), namely the feature parameters with the same width would be weighted, generating weighted feature maps. Finally, the weighted feature maps  
Figure 7: Structure of Triplet attention module. are rotated 90 degrees clockwise along axis H to output \(X_{H+}\) of the same shape as the input \(X\). The calculation process of this branch can be represented by the following equation:  
\[X_{H+}=\mathrm{R}^{\mathrm{H}+}(X_{H}\cdot\sigma(\mathrm{ConvBN}(\mathrm{C}\text {-pool}(X_{H})))) \tag{3}\]  
where, \(\mathrm{R}^{\mathrm{H}+}\) represents clockwise rotation of 90 degrees along the H axis, \(\sigma\) represents Sigmoid activation function, ConvBN represents combination operation of convolution and batch normalization, and C-pool represents compound pooling.