Adapting Stepsizes by Momentumized Gradients Improves Optimization and Generalization

Yizhou Wang, Yue Kang, Can Qin, Yi Xu, Huan Wang, Yulun Zhang, Yun Fu

Abstract: Adaptive gradient methods, e.g. Adam, have achieved tremendous success in machine learning. Scaling the learning rate element-wisely by a certain form of second moment estimate of gradients, such methods are able to attain rapid training of modern deep neural networks. Nevertheless, they are observed to suffer from compromised generalization ability compared with stochastic gradient descent (SGD) and tend to be trapped in local minima at an early stage during training. Intriguingly, we discover that substituting the gradient in the second raw moment estimate term with its momentumized version in Adam can resolve the issue. The intuition is that gradient with momentum contains more accurate directional information and therefore its second moment estimation is a more favorable option for learning rate scaling than that of the raw gradient. Thereby we propose AdaMomentum as a new optimizer reaching the goal of training fast while generalizing much better. We further develop a theory to back up the improvement in generalization and provide convergence guarantees under both convex and nonconvex settings. Extensive experiments on a wide range of tasks and models demonstrate that AdaMomentum exhibits state-of-the-art performance and superior training stability consistently.

Introduction

In modern deep learning, practitioners often face a difficult choice: use Stochastic Gradient Descent with Momentum (SGDM) for superior final generalization, or use Adam for faster training and easier hyperparameter tuning. Adam often suffers from a "generalization gap"—performing well on training data but falling short on unseen test data compared to SGD. Furthermore, Adam can become trapped in sharp local minima early in training.

The authors identify a specific culprit: Adam scales the learning rate based on the second moment of raw gradients. Because raw gradients are inherently noisy, this scaling can be erratic, leading to suboptimal step sizes that either stall training at critical junctions or cause the model to overshoot stable basins.

The AdaMomentum Optimizer

The core innovation of AdaMomentum is a deceptively simple but mathematically profound change to the update rule. Standard Adam maintains an Exponential Moving Average (EMA) of the gradient ($m_t$) and an EMA of the squared raw gradient ($v_t$). AdaMomentum replaces the raw gradient in the $v_t$ calculation with the momentum term itself.

Comparison of update rules for various optimizers. AdaMomentum (Ours) uses the momentumized gradient $m_i^2$ for the second moment estimate $v_t$, creating a twofold EMA.

This "Twofold EMA" approach uses $m_t$ (the momentum), which is already a smoothed, more accurate estimate of the descent direction than the noisy raw gradient $g_t$. Using it to scale the learning rate provides a more "informed" adaptation. Additionally, the authors moved the damping term ($\epsilon$) inside the square root ($\sqrt{v_t + \epsilon}$), which their analysis shows further reduces step sizes near convergence, enhancing stability.

Theoretical Insights and Optimization Behavior

Using a theoretical framework of Lévy-driven Stochastic Differential Equations (SDEs), the authors prove that AdaMomentum has a longer "escaping time" from flat or asymmetric basins than Adam. This means it is more likely to settle into wide, flat minima, which are strongly correlated with high generalization performance.

Visualization of optimization behavior across different loss landscape regions. AdaMomentum maintains better step sizes in steep regions (A, B) and avoids getting trapped in sharp local minima (Zoom) compared to Adam.

Key behavioral advantages include:

  • The "Corner" Advantage: When sliding down a steep loss curve, raw gradients explode. Adam reacts by immediately shrinking the step size, which can stall progress. Because AdaMomentum uses an EMA of the gradient, its denominator grows more slowly, allowing the model to maintain speed through these regions.
  • Stability Near Minima: Conversely, when approaching a minimum, raw gradients vanish. Adam might prematurely increase the effective step size as the denominator shrinks, skipping over the optimum. AdaMomentum’s twofold smoothing keeps the step size controlled in these regions.
  • Hyperparameter Robustness: AdaMomentum works exceptionally well with standard adaptive settings ($\alpha=0.001, \beta_1=0.9, \beta_2=0.999$), making it a drop-in replacement for Adam.

Empirical Performance

The authors evaluated AdaMomentum across a diverse battery of benchmarks, demonstrating state-of-the-art performance:

  • Computer Vision: On ImageNet, AdaMomentum achieved 70.77% top-1 accuracy, effectively matching SGDM (70.73%) and significantly outperforming standard Adam (64.99%).
  • Language Modeling: In LSTM-based modeling (Penn Treebank), AdaMomentum consistently achieved the lowest perplexity across various model depths, beating Adam, AdamW, and AdaBelief.
  • Generative Modeling: For GAN training, AdaMomentum achieved superior FID scores (e.g., 7.16 on BigGAN vs. Adam's 7.24), indicating better image quality and diversity.

Conclusion

AdaMomentum offers a compelling "best of both worlds" solution, providing the rapid convergence and ease of use associated with Adam alongside the high-fidelity generalization results typically reserved for SGD. While it shares the memory requirements of Adam (two state buffers), its superior stability and ability to find flatter minima make it a powerful tool for modern deep learning tasks. Future work may explore integration with Nesterov’s Accelerated Gradient or performance at the scale of multi-billion parameter foundation models.

Summary updated

Abstract

Adaptive gradient methods, e.g. \textsc{Adam}, have achieved tremendous success in machine learning. Scaling the learning rate element-wisely by a certain form of second moment estimate of gradients, such methods are able to attain rapid training of modern deep neural networks. Nevertheless, they are observed to suffer from compromised generalization ability compared with stochastic gradient descent (\textsc{SGD}) and tend to be trapped in local minima at an early stage during training. Intriguingly, we discover that substituting the gradient in the second raw moment estimate term with its momentumized version in \textsc{Adam} can resolve the issue. The intuition is that gradient with momentum contains more accurate directional information and therefore its second moment estimation is a more favorable option for learning rate scaling than that of the raw gradient. Thereby we propose \textsc{AdaMomentum} as a new optimizer reaching the goal of training fast while generalizing much better. We further develop a theory to back up the improvement in generalization and provide convergence guarantees under both convex and nonconvex settings. Extensive experiments on a wide range of tasks and models demonstrate that \textsc{AdaMomentum} exhibits state-of-the-art performance and superior training stability consistently.
BibTeX
@inproceedings{wang2022adapting,
  author = {Yizhou Wang and Yue Kang and Can Qin and Yi Xu and Huan Wang and Yulun Zhang and Yun Fu},
  title = {{Adapting Stepsizes by Momentumized Gradients Improves Optimization and Generalization}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=R6hvtDTQmb},
}
Figure