Promoting Exploration in Memory-Augmented Adam using Critical Momenta

Pranshu Malviya, Gonçalo Mordido, Aristide Baratin, Reza Babanezhad Harikandeh, Jerry Huang, Simon Lacoste-Julien, Razvan Pascanu, Sarath Chandar

TL;DR

Adam+CM (Critical Momenta) is a new memory-augmented optimizer that helps deep learning models escape sharp, poorly-generalizing local minima. By maintaining a buffer of past momentum terms, it encourages the optimizer to "overshoot" narrow pits in the loss landscape and settle in flatter regions, leading to significant performance gains in both vision and language tasks.

What Problem Does This Paper Address?

In deep learning, the "shape" of the minimum your model converges to matters immensely. Sharp minima—narrow, steep pits in the loss landscape—often lead to poor generalization, meaning the model performs well on training data but fails on new, unseen data. Conversely, flatter minima tend to generalize much better.

While the popular Adam optimizer is prized for its speed and ease of use, it is notorious for getting stuck in these sharp minima. Previous attempts to fix this, like Adam+CG (Critical Gradients), used a memory buffer of past gradients to add inertia. However, these methods often suffer from gradient cancellation: in a sharp basin, gradients on opposite sides point in opposite directions and cancel each other out, leaving the optimizer trapped.

Methods

The authors introduce Adam with Critical Momenta (Adam+CM). Instead of storing raw gradients, it stores a buffer of past momentum terms.

Key components include:

  • Priority Buffer: The optimizer maintains a fixed-size buffer of "critical" momenta. A new momentum term enters the buffer if its corresponding gradient has a large $l_2$-norm (indicating it's from a steep, potentially "critical" region).
  • Momentum Aggregation: During the update step, the optimizer doesn't just use the current momentum; it uses an aggregate (average) of the current momentum and all momenta stored in the buffer.
  • Overshooting Mechanism: This aggregated momentum acts like physical inertia. It prevents the optimizer from stopping immediately when it hits a narrow minimum, forcing it to "overshoot" and continue exploring until it finds a basin wide enough to "fill" the buffer and allow convergence.
Figure 1: (Left) Learning trajectories for different optimizers on the Goldstein-Price loss function starting from different initial points. While the other optimizers get stuck in sub-optimal surfaces, Adam+CM explores a lower loss surface and is able to reach the global minimum. (Right) Pseudo-code for Adam with critical momenta (Adam+CM).

Datasets

The authors evaluated Adam+CM across a diverse set of benchmarks:

  • Toy Functions: 1D and 2D non-convex surfaces (Goldstein-Price, Ackley, Levy) to visualize trajectories.
  • Image Classification: CIFAR-10, CIFAR-100, and the large-scale ImageNet dataset using ResNet34 and EfficientNet-B0.
  • Language Modelling: The Penn Treebank (PTB) dataset using an LSTM network.
  • Online Learning: TinyImageNet and a "5-dataset" stream (CIFAR10, MNIST, Fashion-MNIST, SVHN, notMNIST) to test how well the optimizer adapts to changing tasks.

Key Insights and Ideas

  • Solving Gradient Cancellation: By using momenta instead of gradients, the optimizer smooths out the high-variance directional changes found in sharp basins. This prevents the "cancellation" effect that traps other memory-augmented optimizers.
  • Exploration through Inertia: The buffer size effectively controls the "width" of the minima the optimizer can ignore. A larger buffer requires the model to stay in a basin longer to converge, naturally biasing it toward wider, flatter regions.
  • Complementary to SAM: The authors found that Adam+CM can be combined with Sharpness-Aware Minimization (SAM). While SAM focuses on local flatness, CM focuses on global exploration, and together they can sometimes achieve even better results.
Figure 2: First 10 steps of Adam+CG and Adam+CM trajectories on Ackley loss surface. Coloured diamonds represent the final points reached by the optimizers. Gradient cancellation is observed in Adam+CG as buffer mean and new gradients cancel each other out, yielding a small update. Conversely, Adam+CM escapes sub-optimal minima and converges near the global minimum.

Key Results

Adam+CM consistently outperformed standard Adam and other variants across all tested domains:

  • ImageNet: Achieved 71.7% validation accuracy, a significant jump over Adam's 67.8%.
  • Language Modeling (PTB): Reduced validation perplexity to 163.2 (lower is better), compared to 179.4 for standard Adam.
  • Generalization: In toy experiments, Adam+CM reached the global minimum in cases where every other optimizer (including Adam+SAM) got stuck in sub-optimal sharp regions.
  • Efficiency: Despite the extra memory for the buffer, the computational overhead is minimal, and it often converges faster in terms of wall-clock time for online learning tasks.

Limitations and Future Work

  • Theoretical Assumptions: The convergence analysis relies on simplifying assumptions, such as quadratic loss functions and commuting Hessian matrices, which don't perfectly mirror complex deep neural networks.
  • Hyperparameter Tuning: While robust, the method introduces new hyperparameters like buffer capacity ($C$) and decay rate ($\lambda$) that may require tuning for optimal performance.
  • Future Directions: The authors suggest exploring Adam+CM in Reinforcement Learning, where escaping local optima and transferring knowledge between tasks is a major hurdle. They also aim to investigate if CM can capture even higher-order dynamics of the loss landscape.

Summary updated

BibTeX
@misc{malviya2023promoting,
  author = {Pranshu Malviya and Gonçalo Mordido and Aristide Baratin and Reza Babanezhad Harikandeh and Jerry Huang and Simon Lacoste-Julien and Razvan Pascanu and Sarath Chandar},
  title = {{Promoting Exploration in Memory-Augmented Adam using Critical Momenta}},
  year = {2023},
  eprint = {2307.09638},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.09638},
}
Figure