Foundations to Frontier
Tests
A. Mathematical Foundations › A6 Optimization › Optimization for ML

Adaptive Methods: AdaGrad, RMSProp, Adam and AdamW

Different parameters need different step sizes: a bias term, an embedding of a rare word and a convolution filter can have gradients that differ by orders of magnitude. Adaptive methods give every coordinate its own step, scaled by the history of its gradients. You will derive AdaGrad, RMSProp and Adam (momentum plus RMS scaling plus bias correction), understand their invariance to diagonal rescaling, their known pitfalls, and why AdamW's decoupled weight decay differs from L2 regularization inside Adam.

Level 0: Foundation

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

Every knob gets its own speed

Imagine tuning a machine with two knobs. One is ultra-sensitive, so a hair’s turn changes everything. The other barely does anything unless you crank it. Turning both by the same amount is either reckless for the first or useless for the second. Better: watch how strongly each knob has been reacting and adjust each one’s step accordingly.

Adaptive optimizers do exactly this for every parameter of a model. Adam, the most popular, also keeps a running average of the direction (momentum).

One step size per coordinate: RMSProp and Adam
■ GD + momentum (η = 1/s): 56 steps■ RMSProp (η = 0.050): 61 steps■ Adam (η = 0.050): 142 steps
GD must keep η below 2/s for the stiff y-axis, so it crawls along x once s is large (try s = 1000). RMSProp and Adam rescale each coordinate by the RMS of its recent gradients, so both axes take steps of size about η. Their speed hardly depends on s. Adam adds momentum (a smoothed gradient) plus bias correction. With noise, adaptive methods hover near the minimum at a distance set by η; shrinking η (a schedule, A6.3-7) tightens it.
Why engineers care

Adam and AdamW are the default optimizers for transformers, perception networks and most deep RL agents. They make training robust to poorly scaled parameters and need little tuning. Knowing their quirks (bias correction, ε, weight-decay coupling, warmup) prevents silent failures.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Adaptive methods give each parameter…
  2. 2. A parameter whose gradients are always huge gets…
  3. 3. Adam combines RMS scaling with…

Level 1: Beginner

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

Three algorithms (per coordinate, element-wise)

  • AdaGrad (Duchi, Hazan and Singer, 2011): vt=vt−1+gt2v_t = v_{t-1} + g_t^2 and xt+1=xt−ηgt/(vt+ε)x_{t+1} = x_t - \eta g_t/(\sqrt{v_t} + \varepsilon). Rare features keep big steps. The steps only ever shrink.
  • RMSProp (Hinton, 2012): vt=β2vt−1+(1−β2)gt2v_t = \beta_2v_{t-1} + (1 - \beta_2)g_t^2. An exponential moving average forgets old gradients.
  • Adam (Kingma and Ba, 2015):
mt=β1mt−1+(1−β1)gt,vt=β2vt−1+(1−β2)gt2m^t=mt/(1−β1t),v^t=vt/(1−β2t)xt+1=xt−η m^t/(v^t+ε)\begin{aligned}m_t &= \beta_1m_{t-1} + (1 - \beta_1)g_t, & v_t &= \beta_2v_{t-1} + (1 - \beta_2)g_t^2\\ \hat m_t &= m_t/(1 - \beta_1^t), & \hat v_t &= v_t/(1 - \beta_2^t)\\ x_{t+1} &= x_t - \eta\,\hat m_t/(\sqrt{\hat v_t} + \varepsilon)\end{aligned}

Defaults: β1=0.9\beta_1 = 0.9, β2=0.999\beta_2 = 0.999, ε=10−8\varepsilon = 10^{-8}.

Each Adam step moves a coordinate by roughly η\eta times a ratio between −1 and 1. The step size is about η\eta in parameter units, whatever the gradient’s magnitude.

📝 Quick check (Level 1)
0/3 answered
  1. 1. AdaGrad's effective step…
  2. 2. RMSProp replaces AdaGrad's sum by…
  3. 3. Adam's first step moves each coordinate by about…

Level 2: Intermediate

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

Why bias correction?

mm and vv start at 0, so early averages are biased toward 0. With a constant gradient gg, mt=(1−β1t)gm_t = (1 - \beta_1^t)g. Dividing by 1−β1t1 - \beta_1^t recovers gg. For β2=0.999\beta_2 = 0.999 the correction matters for the first few thousand steps.

Invariance and its limits

Rescaling a coordinate, xi→cxix_i\to cx_i, scales its gradient by 1/c1/c. Adam’s ratio m^/v^\hat m/\sqrt{\hat v} is unchanged (as ε→0\varepsilon\to0), so Adam is invariant to diagonal rescaling. That’s why it tolerates badly scaled networks. It is not invariant to rotations, unlike Newton’s method. It’s a diagonal preconditioner (A6.3-6).

Known issues and fixes

  • Non-convergence: Adam can fail on simple convex problems. AMSGrad keeps max⁡v\max v (Reddi, Kale and Kumar, 2018).
  • Warmup: early v^\hat v estimates are noisy, so a learning-rate warmup helps (Liu et al., 2020, RAdam).
  • Generalization: adaptive methods can generalize worse than SGD + momentum on some vision tasks (Wilson et al., 2017).
  • Weight decay: adding λw\lambda w to the gradient (L2) gets rescaled by 1/v^1/\sqrt{\hat v}. AdamW applies w←w−ηλww\leftarrow w - \eta\lambda w separately, giving the same decay rate to every weight (Loshchilov and Hutter, 2019). It’s now the standard for transformers.
🐍 Exercise 1: rescaling invariance
Implement GD, AdaGrad, RMSProp and Adam. On f = ½(x₁² + s·x₂²), show that GD's iteration count explodes with s while Adam and AdaGrad hardly change, and that Adam's first step is about lr in every coordinate.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Adam is invariant to…
  2. 2. AMSGrad fixes Adam's non-convergence by…
  3. 3. AdamW differs from Adam + L2 because its decay is…

Level 3: Advanced

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

Deriving bias correction

Unrolling, mt=(1−β1)∑i=1tβ1t−igim_t = (1 - \beta_1)\sum_{i=1}^t\beta_1^{t-i}g_i. If E[gi]=gˉ\mathbb E[g_i] = \bar g is stationary, then E[mt]=(1−β1)gˉ∑i=1tβ1t−i=(1−β1t)gˉ\mathbb E[m_t] = (1 - \beta_1)\bar g\sum_{i=1}^t\beta_1^{t-i} = (1 - \beta_1^t)\bar g. Dividing by 1−β1t1 - \beta_1^t gives an unbiased estimate. The same holds for vtv_t and E[g2]\mathbb E[g^2]. ∎

Diagonal-rescaling invariance

Let y=Dxy = Dx with DD diagonal. Gradients in yy are D−1gD^{-1}g, so my=D−1mxm_y = D^{-1}m_x and vy=∣D−1∣vx\sqrt{v_y} = |D^{-1}|\sqrt{v_x}. The step in yy is −η sign⁡(D−1)mx/vx-\eta\,\operatorname{sign}(D^{-1})m_x/\sqrt{v_x}, which is the same normalized step in every coordinate. Mapped back, iterates in xx differ only by the coordinate scaling of the step size. Convergence speed in terms of normalized progress is unchanged. ∎

Why L2 inside Adam isn’t weight decay

With L2, the update is −η(g+λw)/v^-\eta(g + \lambda w)/\sqrt{\hat v}. Weights with a large gradient history (large v^\hat v) are regularized less, and weights with small gradients more. Adam + L2 converges toward the minimizer of the L2-penalized objective (ridge), which crushes low-variance features. AdamW’s decay −ηλw-\eta\lambda w is the same fraction for every weight per step, independent of gradient statistics.

Exercise 3.1: RMSProp step size under a constant gradient

With gt=gg_t = g, vt→g2v_t\to g^2, so the step is ηg/g2=η sign⁡(g)\eta g/\sqrt{g^2} = \eta\,\operatorname{sign}(g). It has fixed length η\eta. RMSProp behaves like sign descent with step η\eta.

📝 Quick check (Level 3)
0/3 answered
  1. 1. With constant gradient g, Adam's m_t equals…
  2. 2. Under a constant gradient, RMSProp steps…
  3. 3. Adam + L2 regularizes weights with large gradient history…

Level 4: Expert

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

Weight decay done right

Two features feed a regression: wheel current (variance 100) and IMU tilt (variance 0.01), with true weights 1 and 10. With decay 0.05:

  • Adam + L2 converges to the ridge solution, shrinking the tilt weight from 10 to about 1.7. Ridge punishes low-variance features hardest.
  • AdamW shrinks both weights only slightly (tilt ≈ 9.1), because its decay doesn’t interact with the gradient scale.

Which behaviour you want depends on the goal, but they are not the same algorithm. Confusing them was a common bug before 2019.

🐍 Exercise 2 (research): Adam + L2 vs AdamW
Train a two-feature regression with mini-batch Adam using coupled L2 vs decoupled weight decay. Compare with the ridge solution and the undecayed weights.

Adaptive methods in AI, robotics and aerospace

  • Transformers and LLMs are trained with AdamW plus warmup and cosine decay (A6.3-7).
  • Deep RL for robotics (PPO, SAC) uses Adam almost universally (Schulman et al., 2017; Haarnoja et al., 2018).
  • Neural fields and scene representations for mapping (NeRF, Gaussian splatting) use Adam with per-parameter-group learning rates.
  • Sparse features: AdaGrad remains popular for embeddings and online advertising-scale models (McMahan et al., 2013).

References

  1. J. Duchi, E. Hazan, Y. Singer (2011). “Adaptive subgradient methods for online learning and stochastic optimization.” JMLR, 12.
  2. T. Tieleman, G. Hinton (2012). “Lecture 6.5 — RMSProp.” COURSERA: Neural Networks for Machine Learning.
  3. D. Kingma, J. Ba (2015). “Adam: a method for stochastic optimization.” ICLR.
  4. S. Reddi, S. Kale, S. Kumar (2018). “On the convergence of Adam and beyond.” ICLR.
  5. I. Loshchilov, F. Hutter (2019). “Decoupled weight decay regularization.” ICLR.
  6. L. Liu et al. (2020). “On the variance of the adaptive learning rate and beyond.” ICLR (RAdam).
  7. A. Wilson, R. Roelofs, M. Stern, N. Srebro, B. Recht (2017). “The marginal value of adaptive gradient methods in machine learning.” NeurIPS.
  8. J. Schulman et al. (2017). “Proximal policy optimization algorithms.” arXiv:1707.06347.
  9. T. Haarnoja et al. (2018). “Soft actor-critic: off-policy maximum entropy deep reinforcement learning with a stochastic actor.” ICML.
  10. H. B. McMahan et al. (2013). “Ad click prediction: a view from the trenches.” KDD.