Foundations to Frontier
Tests
E. Deep Learning › E3 Optimizers (one page each)

AMSGrad

AMSGrad is Adam with one change: it divides by the running maximum of the second-moment estimate rather than the estimate itself, so each parameter's effective learning rate can never increase. Reddi, Kale and Kumar introduced it after proving that Adam (and RMSProp) can converge to the worst point on a simple online convex problem, because a short memory lets rare large gradients be forgotten. This page covers the failure mechanism, the fix, its convergence guarantee and its practical cost. In the exercises you show that AMSGrad's effective rate never increases and that one gradient spike keeps it small long afterwards, then reproduce the counterexample: with the paper's short memory Adam converged to the worst point, AMSGrad to the optimum, and with the usual β₂ = 0.999 Adam was fine.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Never forget a big gradient

Adam divides each step by a moving average of recent squared gradients. Suppose a parameter usually gets small gradients but occasionally a large, important one. A short memory forgets the large one quickly, the denominator shrinks, and the steps from the frequent small gradients become relatively large. They can then outweigh the rare large ones and push the parameter the wrong way. AMSGrad keeps the largest denominator seen so far, so rare large gradients are never discounted.

Optimizer lab: AMSGrad versus plain gradient descent
AMSGrad: final loss 0.012 (target reached at step 75) · gradient descent: final loss 2.2e-9 (step 22)
Orange: the chosen optimizer; grey dashed: plain gradient descent with the same learning rate. Darker shading means higher loss. On the ill-conditioned bowl, raise κ and watch gradient descent zig-zag across the narrow direction; on the saddle it stalls near the flat start; on the plateau its gradients are tiny. Adaptive methods rescale each direction; momentum methods build speed along consistent directions. The target is 1% of the starting loss (for the saddle, a loss below −0.2; its minima are at −0.25).
Why engineers care

Rare but large gradients are typical of rare events: faults, unusual manoeuvres, edge-case inputs. An optimiser that systematically underweights them can learn a model that is wrong exactly where it matters. AMSGrad shows the mechanism and one fix. It also shows why β₂ close to 1, a long memory, is the practical default.

📝 Quick check (Level 0)
0/3 answered
  1. 1. AMSGrad divides by…
  2. 2. AMSGrad's effective learning rate can…
  3. 3. AMSGrad was motivated by…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Update: m and v as in Adam, then v_max ← max(v_max, v), and w ← w − η·m/(√v_max + ε). The original paper uses no bias correction for v_max.
  • Example with β₁ = β₂ = 0.5, v_max = 1, g = 1: m = 0.5, v = 0.5, v_max stays 1, step = η × 0.5.
  • The failure (Reddi et al.): on [−1, 1], the loss is Cx on every third step and −x otherwise. The average gradient (C − 2)/3 is positive for C > 2, so the best point is x = −1.
  • What goes wrong: with a short memory, the C-gradient is divided by a large √v, but by the next steps v has decayed, so the two −1 gradients get larger steps. Their combined push toward +1 beats the single push toward −1, and Adam drifts to the worst point.
  • Running maximum: for 1, 3, 2, 5, 4 it is 1, 3, 3, 5, 5.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Running maximum of (2, 1, 4, 3)?
  2. 2. In the counterexample with C = 3 the optimum is…
  3. 3. Adam fails there because the rare large gradient is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

AMSGrad in code

Exercise 1.

  • Along a gradient sequence of ones with a single spike of 50, AMSGrad’s effective learning rate never increased: 1.26 before the spike, 0.198 a thousand steps after.
  • Adam’s recovered to 0.999.
  • The protection has a cost: one outlier gradient can permanently slow AMSGrad’s learning for that parameter.

Practice.

  • PyTorch implements AMSGrad as amsgrad=True on Adam or AdamW, with bias correction on the maximum.
  • In most deep-learning benchmarks AMSGrad performs about the same as Adam, sometimes slightly worse. Its value is mainly theoretical, plus cases with rare large gradients and short memories.
  • Gradient clipping limits the permanent slow-down caused by outlier spikes.
torch.optim.Adam(params, lr=1e-3, amsgrad=True)
🐍 Exercise 1: the running maximum
Implement AMSGrad and compare its effective learning rate with Adam's along a gradient sequence containing one spike.
📝 Quick check (Level 2)
0/3 answered
  1. 1. After a single large gradient spike, AMSGrad's steps…
  2. 2. In PyTorch AMSGrad is enabled with…
  3. 3. On typical deep-learning benchmarks AMSGrad versus Adam is…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

The convergence gap. Adam’s original proof relied on the quantity Γₜ = √vₜ/ηₜ − √vₜ₋₁/ηₜ₋₁ being positive, so that the effective learning rate is non-increasing. With exponential moving averages, vₜ can drop sharply after a large gradient leaves the window, making Γₜ negative. Reddi, Kale and Kumar (2018) built online convex problems where this leads to non-vanishing average regret: Adam converges to a suboptimal point. They also showed a stochastic version and gave conditions involving β₁ and β₂ for the failure.

The fix. Using v̂ₜ = max(v̂ₜ₋₁, vₜ) guarantees Γₜ ≥ 0 with ηₜ = η/√t. AMSGrad then has O(√T) regret (average regret → 0) for online convex problems, like AdaGrad.

What the theory needs. The counterexample requires a second-moment memory short enough to forget the rare gradient between its occurrences (β₂ small compared with the gap). With β₂ = 0.999 the memory spans about 1000 steps, much longer than the period-3 pattern, and Adam converges correctly on that problem, as exercise 2 shows. Failures with practical β₂ need rarer large gradients. Later work (e.g. Zhang et al., 2022) showed that Adam with β₂ chosen as a function of the problem does converge.

📝 Quick check (Level 3)
0/3 answered
  1. 1. AMSGrad's regret for online convex problems is…
  2. 2. The counterexample requires a second-moment memory that is…
  3. 3. Reddi et al.'s paper won…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Reproducing the counterexample

History.

  • D. Kingma and J. Ba (2015) published Adam with a convergence proof that turned out to have a gap.
  • S. Reddi, S. Kale and S. Kumar (2018) exposed it, introduced AMSGrad and won a best-paper award at ICLR.
  • Y. Zhang et al. (2022) showed Adam can converge without modification when β₂ is large enough relative to the problem.

Exercise 2. The online problem on [−1, 1]: loss Cx on steps where t mod 3 = 1, and −x otherwise, for 30 000 steps with ηₜ = 0.1/√t, β₁ = 0 and projection back onto [−1, 1]. Following the paper’s construction, β₂ = 1/(1 + C²), a very short memory; Adam with the usual β₂ = 0.999 is also run. The table gives the final x (the optimum is −1) and the average regret against x = −1.

method C final x average regret
Adam, β₂ = 1/(1 + C²) 2.5 +0.9997 0.331
AMSGrad, β₂ = 1/(1 + C²) 2.5 −0.9998 0.007
Adam, β₂ = 0.999 2.5 −0.9997 −0.001
Adam, β₂ = 1/(1 + C²) 3 +0.9997 0.663
AMSGrad, β₂ = 1/(1 + C²) 3 −0.9998 0.006
Adam, β₂ = 1/(1 + C²) 5 +0.9997 1.991
AMSGrad, β₂ = 1/(1 + C²) 5 −0.9999 0.006
Adam, β₂ = 0.999 5 −0.9998 −0.001
  • The failure is real. With the short memory, Adam converged to x = +1, the worst point, and its average regret grew with C (0.33, 0.66, 1.99) instead of vanishing.
  • AMSGrad converged to the optimum in every case, with regret near zero.
  • With the usual β₂ = 0.999, Adam also converged to −1. The failure depends on a memory short enough to forget the large gradient between occurrences. (A negative average regret is possible early on, while x is still moving toward −1.)
  • Lesson: keep β₂ close to 1 unless there is a reason not to. When lowering β₂ (as some transformer recipes do), be aware of this failure mode for rare, large gradients.
🐍 Exercise 2 (research): reproducing the counterexample
Run Adam and AMSGrad on Reddi et al.'s online convex problem with C = 2.5, 3 and 5 and β₂ = 1/(1 + C²), plus Adam with β₂ = 0.999; compare final points and average regret.

AMSGrad in AI, robotics and aerospace

  • Rare-event learning: models trained on data where informative examples are rare (faults, near-misses) can use AMSGrad or a long β₂ to avoid discounting them.
  • Online learning on deployed systems: convergence guarantees in the online convex setting matter when models adapt continuously.
  • Robust training recipes: a long second-moment memory plus gradient clipping is a pragmatic alternative.

References

  1. S. J. Reddi, S. Kale, S. Kumar (2018). “On the convergence of Adam and beyond.” Proc. ICLR.
  2. D. P. Kingma, J. Ba (2015). “Adam: a method for stochastic optimization.” Proc. ICLR.
  3. Y. Zhang, C. Chen, N. Shi, R. Sun, Z.-Q. Luo (2022). “Adam can converge without any modification on update rules.” Advances in NeurIPS 35.