# Succulent Plant Image Classification Based on Lightweight GoogLeNet with CBAM Attention Mechanism
## 2 Materials and Methods
### Improved Lightweight GoogLeNet  
#### 2.3.1 Cbam  
CBAM is an effective extension to the classical GoogLeNet architecture, aiming to enhance the model's ability to focus on important features by introducing an attention mechanism, thus improving its performance in image classification and target detection tasks. As shown in Figure 1, the CBAM module consists of two components, channel attention and spatial attention, which act sequentially on the feature map, from global information to local features for fine-grained weighting [29]. In these two stages, channel attention focuses on \"which feature\" is more important, while spatial attention focuses on \"where\" is more important. In channel attention, based on the global average pooling and maximum pooling, the attention weight of each channel is generated, and the channels are weighted to highlight the important channels. In spatial attention, based on the average pooling and maximum pooling of channels, a spatial attention map is generated to highlight important spatial locations.  
Firstly, the channel attention mechanism captures the global information of each channel through global average pooling and max pooling, as shown in Equations (1) and (2). Global average pooling and global maximum pooling aggregate the input feature maps through spatial dimensions, as follows:  
\[Avg\_pool(X)=\frac{1}{H\times W}\sum_{i=1}^{H}\sum_{j=1}^{W}X(i,j) \tag{1}\]  
\[Max\_pool(X)=\max X(i,j) \tag{2}\]  
These two pooling approaches process each channel of the input feature map separately to generate two different global feature descriptions. Subsequently, these two features are computed and merged by a multilayer perceptron (MLP) to generate a set of attention weights, as shown in Equation (3).  
\[M_{c}(X)=\sigma(FC2(ReLU(FC1(AVG\_pool(X)))))+\sigma(FC2(ReLU(FC1(AVG\_pool(X))))) \tag{3}\]  
Figure 1: Structure of the CBAM attention mechanism.  
The updated feature map is obtained by weighting each channel of the original feature map and finally multiplying the channel's elements element-wise. This process allows the network to better focus on \"which features\" are more important [29]. The structure of channel attention is shown in Figure 2:  
Next, the channel-weighted feature maps are input to the spatial attention mechanism. As shown in Equations (4) and (5), the spatial attention mechanism first performs average pooling and maximum pooling on the channel dimensions to obtain two 2D feature maps.  
\[Avg(X)=\frac{1}{C}\sum_{c=1}^{C}X(C) \tag{4}\]  
\[Max(X)=\max X(C) \tag{5}\]  
Then, as shown in Equation (6), these two feature maps are convolved with a \(7\times 7\) kernel to generate a spatial attention map, and the spatial attention structure map is shown in Figure 3:  
\[M_{s}(X)=\sigma(\text{Conv }7\times 7([\text{Avg}(X);\text{Max}(X)])) \tag{6}\]  
This attention map is applied to the feature map after the channel update to complete the joint optimization of space and channel. The spatial attention map is weighted to emphasize key spatial regions in the feature map, allowing the model to more accurately identify \"which locations\" are critical to the task [29].