# An Improved Adam's Algorithm for Stomach Image Classification
## 2 Design of the CG-Adam Algorithm
### The CG-Adam Algorithm
The epoch in this experiment is set to 100 to ensure that the algorithms are compared with the same number of training rounds. 2. The batch size in this experiment is set to 128 to maintain the consistency of the experiment. 3. The initial learning rate of all algorithms in this experiment is set to 0.001. 4. Due to the need to adjust the restart period and cropping value of the CG-Adam algorithm, multiple experiments are performed on each dataset, and the best experimental results are selected. 5. Comparison experiments are conducted on the MNIST, CIFAR10, and Stomach datasets, respectively. The CG-Adam algorithm aims to improve the generalization ability of the model and avoid falling into local optima. To test the performance of the CG-Adam algorithm on different neural networks, different types of neural networks were trained on different datasets. A simple fully connected neural network was used for training on the MNIST dataset, and a MobileNetV2 lightweight neural network was used for training on the CIFAR10 and Stomach datasets. In this experiment, in order to present the performance of the CG-Adam algorithm with different combinations of learning rates, three different \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Dataset** & **Optimization Algorithm** & **Accuracy** & **Loss** \\ \hline \multirow{8}{*}{MNIST} & SGD & 97.36\% & 0.091 \\  & Adagrad & 97.84\% & 0.066 \\  & Adadelta & 96.42\% & 0.133 \\  & Adam & 98.52\% & 0.064 \\  & Nadam & 98.50\% & 0.062 \\  & StochGradAdam & 97.82\% & 0.078 \\  & CG-Adam & **98.59\%** & **0.059** \\ \hline \multirow{8}{*}{CIFAR10} & SGD & 49.09\% & 1.467 \\  & Adagrad & 33.54\% & 1.852 \\  & Adadelta & 25.58\% & 1.979 \\  & Adam & 69.55\% & 1.232 \\  & Nadam & 68.87\% & 1.638 \\  & StochGradAdam & 68.07\% & 1.04 \\  & CG-Adam & **70.7\%** & 1.181 \\ \hline \multirow{8}{*}{Stomach} & SGD & 57.6\% & 1.17 \\  & Adagrad & 68.40\% & 0.992 \\ \cline{1-1}  & Adadelta & 55.80\% & 2.110 \\ \cline{1-1}  & Adam & 69.80\% & 1.046 \\ \cline{1-1}  & Nadam & 67.66\% & 2.10 \\ \cline{1-1}  & StochGradAdam & 67.2\% & 1.166 \\ \cline{1-1}  & CG-Adam & **73.2\%** & 1.020 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: The comparison of the experimental results for different optimization algorithms. combinations were designed. The performance of the CG-Adam algorithm on the CIFAR10 dataset when combined with different learning rates is shown in Figure 1.

In Figure 1, it is shown that in the three sets of experiments with different learning rates, the CG-Adam algorithm with a learning rate of 0.001 achieves the optimal values of acc and loss, so the learning rate of 0.001 is set as the initial value of the CG-Adam algorithm. The training results of the seven algorithms on the MNIST dataset are shown in Figure 2.

The training results of the seven algorithms on the CIFAR10 dataset are shown in Figure 3.

Figure 1: The comparison of performance with different learning rates on the CIFAR10 dataset. (**a**) The comparison of accuracy. (**b**) The comparison of loss values. Figure 3: The training results of the seven algorithms on the CIFAR10 dataset. (**a**) The comparison of accuracy. (**b**) The comparison of loss values. Figure 2: The training results of the seven algorithms on the MNIST dataset. (**a**) The comparison of accuracy. (**b**) The comparison of loss values. The training results of the seven algorithms on the Stomach dataset are shown in Figure 4.

As can be seen in Figure 4, the SGD algorithm and Adadelta algorithm significantly lag behind the other algorithms in terms of accuracy and loss values. The CG-Adam algorithm shows high accuracy from the beginning of the training phase, especially when compared to other algorithms based on the improvement of Adam (e.g., the Nadam algorithm and the StochGradAdam algorithm). This achievement is attributed to CG-Adam's controlled restart strategy, which resets the algorithm's state when a specific cycle is reached, thus indirectly enabling efficient tuning of the learning rate.