# Dynamic Graph Neural Network for Garbage Classification Based on Multimodal Feature Fusion
## 2 Multimodal Feature Fusion for Image Preprocessing and Feature Enhancement
### Attention Module  
The attention module comprises two components, channel attention and spatial attention, which are designed to enhance feature representations along the channel and spatial dimensions, respectively. As illustrated in Figure 1, this schematic depicts the attention module architecture utilized in our study.  
Figure 1: Attention module structure diagram.  
Channel attention enables the network to learn which channels are most discriminative based on the global responses of each channel, thereby enhancing these channels while suppressing less informative ones. Unlike the channel attention module in CBAM [35], which employs both average and max pooling, we exclusively utilize average pooling. The rationale is that the global feature distribution information provided by average pooling is entirely sufficient for effective channel attention learning and helps to avoid neglecting other crucial information due to local extreme values. Global average pooling:  
\[F_{avg}[c]=\frac{1}{H\times W}\sum_{x-1}^{H}\sum_{y-1}^{W}X[c,x,y] \tag{1}\]  
Here, \(X\in\mathbb{R}^{C\times H\times W}\) represents the input feature map, and a global average is computed for each channel to yield the vector \(\mathbb{R}^{C}\).  
Fully Connected Layers:  
\[M_{c}(X)=\sigma\big{(}Conv2D\big{(}\delta\big{(}Conv2D\big{(}F_{avg}\big{)} \big{)}\big{)}\big{)} \tag{2}\]  
Here, \(\delta\) denotes the ReLU activation function, \(\sigma\) represents the Sigmoid activation function, and \(Conv2D\big{(}F_{avg}\big{)}\) corresponds to a fully connected layer that outputs the channel attention.  
Element-wise Multiplication:  
\[X^{\prime}=X\otimes M_{c}(X) \tag{3}\]  
Here, \(M_{c}(X)\in\mathbb{R}^{C\times 1\times 1}\) corresponds to the channel-wise weighting, while \(X^{\prime}\in\mathbb{R}^{C\times H\times W}\) represents the channel-enhanced features. The structure of our channel attention module is depicted in Figure 2.  
Spatial attention further weights the internal pixel positions within each channel, guiding the network to focus on regions of significant relevance. We adopt the spatial attention module from CBAM because spatial information exhibits strong local distinctiveness. The combination of max pooling and average pooling more comprehensively captures the fine-grained variations in key regions, thereby enhancing the model's sensitivity and accuracy in localizing critical spatial features.  
Max Pooling and Average Pooling:  
\[X_{cat}=\big{[}\max\big{(}X^{\prime},\dim=1\big{)},mean\big{(}X^{\prime},\dim= 1\big{)}\big{]}\in\mathbb{R}^{2\times H\times W} \tag{4}\]  
Specifically for \(X^{\prime}\), max pooling and average pooling are each applied along the channel dimension to obtain \(\mathbb{R}^{1\times H\times W}\), which are then concatenated along the channel dimension to yield \(2\times H\times W\).  
Figure 2: Channel attention module structure diagram.  
Convolution-Based Spatial Attention Learning:  
\[M_{s}\big{(}X^{\prime}\big{)}=\sigma(Conv2D_{7\times 7}(X_{cat})) \tag{5}\]  
The output, \(\mathbb{R}^{1\times H\times W}\), denotes the importance of each spatial location.  
Element-wise Multiplication:  
\[X_{out}=X^{\prime}\otimes M_{s}\big{(}X^{\prime}\big{)} \tag{6}\]  
Here, \(X_{out}\in\mathbb{R}^{C\times H\times W}\) is the final feature map enhanced along both the channel and spatial dimensions. The structure of our spatial attention module is illustrated in Figure 3.