# An Improved Adam's Algorithm for Stomach Image Classification
## 2 Design of the CG-Adam Algorithm
### The CG-Adam Algorithm
MNIST is a binary image dataset containing handwritten digits. CIFAR-10 is a dataset containing color images for the image classification task. The images cover a wide range of object classes. The Stomach image dataset encompasses multiple categories. Characterizations of the datasets are shown in Table 2.

The Stomach dataset is a medical image dataset focused on gastrointestinal diseases. It contains over 110,000 high-quality images and a large amount of video data, all collected and annotated by specialized medical experts from the same Behram Hospital. This dataset is valuable for the automated detection and categorization of gastrointestinal diseases, as well as for medical education and research. Through the application of machine learning and data analytics, this gastrointestinal dataset helps facilitate the development of medical technology and improve the accuracy of clinical diagnosis. In this paper, experiments were conducted using 1885 labeled images from this dataset. ### Experimental Results and Analysis

The improved algorithm proposed in this paper inherits the advantages of the adaptive learning rate of the Adam algorithm and enhances the robustness and efficiency of the whole optimization process. This improvement strategy makes the CG-Adam algorithm more suitable for a wide range of deep learning tasks, especially when encountering gradient instability and optimization challenges, and ensures more reliable performance. In order to thoroughly evaluate the performance benefits of the CG-Adam algorithm, this study selected the SGD algorithm, Adagrad algorithm, Adadelta algorithm, and Adam algorithm, and the improved algorithms, the Nadam algorithm and the StochGradAdam algorithm, and conducted a series of comparative experiments. Through extensive testing on multiple datasets and under different learning rate settings, the aim is to gain a deeper understanding of the performance of these algorithms. The comparison of the experimental results for different optimization algorithms is shown in Table 3. The reason for the bold numbers in the table is that CG-Adam shows the best results when compared to the other six algorithms. \begin{table}
\begin{tabular}{c c} \hline
**Software** & **Version** \\ \hline Python & 3.10 \\ torch & 2.0.1 \\ torchvision & 0.15.0 \\ lightning & 2.1.2 \\ Wandb & 0.16.0 \\ \hline \end{tabular}
\end{table} 
Table 1: The specific versions of the software mainly used in the experiment. \begin{table}
\begin{tabular}{c c c c c c} \hline
**Dataset** & \
\begin{tabular}{c} **Number of** \\ **Samples** \\ \end{tabular} & **Training Set** & **Test Set** &
\begin{tabular}{c} **Validation** \\ **Set** \\ \end{tabular} & **Category** \\ \hline MNIST & 70,000 & 55,000 & 10,000 & 5000 & 10 \\ CIFAR10 & 60,000 & 45,000 & 10,000 & 5000 & 10 \\ Stomach & 1885 & 900 & 485 & 500 & 8 \\ \hline \end{tabular}
\end{table} 
Table 2: Characterizations of the datasets. Based on the comparative experimental data in Table 3, it can be concluded that the performance of the improved CG-Adam algorithm is superior to the performance of the unimproved Adam algorithm. The accuracy of the CG-Adam algorithm on the CIFAR10 dataset reaches 70.7%, which is 1.15% higher than that of the unimproved Adam algorithm, and the loss value of the CG-Adam algorithm is 1.181, which is 0.051 lower than that of the unimproved Adam algorithm. The accuracy of the CG-Adam algorithm on the Stomach dataset reaches 73.2%, which is 3.4% higher than that of the unimproved Adam algorithm, and the loss value of the CG-Adam algorithm is 1.020, which is 0.026 lower than that of the unimproved Adam algorithm. The CG-Adam algorithm achieves better accuracy on all three datasets, which demonstrates that the proposed CG-Adam algorithm can be used in the processing of different types of datasets (both basic black-and-white images and more complex color RGB images) and verifies its outstanding generalization capability. The experimental setup was as follows:

1.