# Dynamic Graph Neural Network for Garbage Classification Based on Multimodal Feature Fusion
## 4 Loss Function and Optimization
### Cosine Annealing Scheduler  
During model training, to enhance both convergence speed and generalization performance, we adopt a cosine annealing scheduling strategy to adjust the learning rate. The update formula is given as follows:  
\[\eta_{t}=\eta_{\text{min}}+\frac{1}{2}(\eta_{\text{max}}-\eta_{\text{min}}) \biggl{(}1+\cos\biggl{(}\frac{T_{cur}}{T_{\text{max}}}\pi\biggr{)}\biggr{)} \tag{22}\]  
Here, \(t\) denotes the current training iteration, \(T_{cur}\) represents the number of iterations already executed, and \(T_{\text{max}}\) indicates the predetermined maximum annealing cycle. This cosine annealing strategy enables the learning rate to decrease following a cosine curve during the training process, affecting a gradual decay that is conducive to fine-tuning the model in later stages. Moreover, cosine annealing can be combined with a restart mechanism, allowing for periodic reinitialization of the learning rate throughout training to further enhance model convergence. Building upon the aforementioned studies, this work proposes a classification method based on a dynamic graph neural network model that fuses multimodal features, aimed at improving the accuracy and robustness of garbage classification. The overall logical framework is illustrated in Figure 8, and the specific steps are outlined as follows:Step 1: Data augmentation strategies are applied to the input images, including random color jitter, grayscale transformations, Gaussian blurring, rotation, and flipping. These operations emulate variations in illumination and viewing angles encountered in real-world scenarios, thereby enhancing the model's robustness to complex environments. Step 2: An improved deep convolutional neural network, RNAM, is employed to extract high-level visual features from the raw images. Meanwhile, color space transformations and histogram calculations are utilized to capture the color distribution information of the images, allowing for a more comprehensive representation of the data. Step 3: The deep visual features extracted by the RNAM network are concatenated with the LAB histogram features, effectively integrating two complementary modalities and yielding a multimodal feature vector that encompasses both global and local information. Step 4: Based on these multimodal features, an adaptive K-nearest neighbor algorithm is used to construct a graph structure, dynamically adjusting the number of neighbors and adaptively selecting neighboring relationships among the features. This process realizes adaptive connectivity between graph nodes, capturing salient graph structural properties. Step 5: A multi-layer graph attention network is employed to efficiently extract features from the constructed graph. By combining global average pooling and a fully connected layer to classify the resulting graph embeddings, the framework achieves precise recognition and classification of garbage images. Figure 8: Overall logical framework diagram. The complete process of the multimodal feature fusion-based dynamic graph neural network model classification algorithm is provided in Algorithm 1:  
```
Input:\(D_{train}=\left\{(x_{i},y_{i})\right\}_{i=1}^{N_{train}}\), \(D_{test}=\left\{(x_{i},y_{i})\right\}_{i=1}^{N_{test}}\), \(\theta=\left\{bs,k,T,\alpha,h,p,\lambda\right\}\) where\(bs\): batch size, \(k\): initial number of neighbors, \(T\): number of epochs, \(\alpha\): learning rate, \(h\): number of heads, \(p\): dropout probability, \(\lambda\): weight decay Output: Best test accuracy \(A_{best}\) Define:\(A(x)\): augmentation \(CNN(x)\): RNAM for deep feature extraction \(Hist(x)\): LAB histogram features \(F=CNN(A(x))\oplus Hist(x)\): fused features (\(\oplus\) denotes concatenation) \(E=DynamicKNN(F,k^{\prime})with\)\(k^{\prime}=\min(k,N-1)\) \(G=(F,E,y)\): graph data \(GNN(G)\): graph neural network (based on GATv2 Conv) \(L=CE(\hat{y},y)\): cross-entropy loss
```  
**Process: 1.