# An Improved Adam's Algorithm for Stomach Image Classification
## 2 Design of the CG-Adam Algorithm
### Control Restart Strategy  
The core idea of the control restart strategy is to periodically check the number of steps during the optimization process and perform a restart operation once the number of steps reaches a predefined restart period. The restart operation consists of resetting the optimizer state and the step counter to their initial values so that the optimization process can restart in the next cycle. The introduction of this restart strategy effectively improves the robustness and efficiency of the optimization algorithm. By dynamically adjusting the restart cycle, the algorithm is able to adaptively optimize according to the characteristics of the problem, further improving its performance. This flexible restart strategy provides an effective solution for the application of optimization algorithms to cope with optimization challenges in different scenarios. In addition to this, the control restart strategy has some additional advantages. It prevents the optimization process from falling into local optimal solutions and thus explores better global solutions. In addition, the strategy is able to better handle non-convex optimization problems by restarting the optimization process periodically, which makes the optimizer perform better in the face of complex and multi-peaked loss functions. Taken together, the control restart strategy not only improves the robustness and efficiency of the algorithm but also enhances the adaptability and stability of the algorithm in dealing with complex optimization problems, making it an indispensable and important technique in solving practical optimization tasks. The control restart strategy is shown in Equation (8):  
\[t^{\prime}=\text{fmod}T \tag{8}\]  
In Equation (8), \(t\) is the current number of iterations; mod denotes the modulo operation; and \(t^{\prime}\) denotes the control of the step count within a cycle T when executing a restart cycle. The step counter \(t^{\prime}\) indicates the number of steps in the current cycle. At the beginning, \(t^{\prime}\) is initialized to 0, and the value of \(t^{\prime}\) is increased by 1 for each step performed as the optimization process proceeds. The value of \(t^{\prime}\) is reset to 0 when \(t^{\prime}\) reaches the cycle length T in order to restart the counting, thus completing one cycle. The introduction of this restart cycle effectively controls the step counting of the optimization algorithm so that the number of steps in each cycle can be well controlled and managed, thus improving the stability and efficiency of the optimization algorithm. The deviation correction factor takes into account the restart logic, and the deviation correction formula can be redefined, as shown in Equations (9)-(12):  
\[m_{t^{\prime}}=\beta_{1}m_{t^{\prime}-1}+(1-\beta_{1})g_{t} \tag{9}\]  
\[v_{t^{\prime}}=\beta_{2}v_{t^{\prime}-1}+(1-\beta_{2})g_{t}^{2} \tag{10}\]  
\[\dot{m}_{t^{\prime}}=m_{t}/\left(1-\beta_{1}^{t^{\prime}}\right) \tag{11}\]  
\[\dot{v}_{t^{\prime}}=v_{t}/\left(1-\beta_{2}^{t^{\prime}}\right) \tag{12}\]  
In Equations (9)-(12), the restart strategy converts the timestamp \(t\) into \(t^{\prime}\), which gives the parameter update process the property of periodic adjustment through \(t^{\prime}\) and is able to better adapt to the periodically changing data distribution and model parameters. These adjustments not only take into account the bias correction and dynamic adjustment of the gradient estimation in each cycle but also ensure the periodic impact of the bias correction, thus improving the stability and generalization performance of the algorithm. The formula for _denom_ is shown in Equation (13):  
\[denom=\sqrt{\dot{\dot{v}}_{t}+\epsilon} \tag{13}\]  
In Equation (13), _denom_ denotes the denominator term in the step adjustment; \(\dot{\dot{v}}_{t}\) denotes the bias-corrected second-order moment estimate, which represents the movingaverage of the squared gradient; and \(\varepsilon\) denotes a small constant that is usually used to prevent the denominator from being zero.