AI / ML Theory
Chapter 3 · 18 min

3.4 — AdaGrad and RMSProp: per-parameter adaptive learning rates

Goal: Derive AdaGrad's per-parameter scaling, see why it stalls, and fix it with RMSProp's exponential moving average of squared gradients.

1. Why this session exists

Momentum gives every parameter the same learning rate α\alpha. That is a problem when some parameters see large gradients all the time (embeddings of frequent tokens, biases in the active part of a ReLU) and others see tiny ones (embeddings of rare tokens, weights in a saturated region). One global α\alpha is too aggressive for the noisy parameters and too cautious for the quiet ones.

The fix is per-parameter adaptive learning rates: divide each coordinate's step by a measure of how big its gradients have historically been. AdaGrad does this with a cumulative sum; RMSProp replaces the sum with an EMA. Adam will combine RMSProp with momentum in 3.5.


2. AdaGrad

Duchi et al. (2011)[1]. For each parameter coordinate ii, keep a running sum of squared gradients

Gt(i)=∑k=1t(gk(i))2,G_t^{(i)} = \sum_{k=1}^t \bigl(g_k^{(i)}\bigr)^2,

and use it to scale the step element-wise:

 θt+1(i)=θt(i)−αGt(i)+ε gt(i). \boxed{\ \theta_{t+1}^{(i)} = \theta_t^{(i)} - \frac{\alpha}{\sqrt{G_t^{(i)} + \varepsilon}}\, g_t^{(i)}. \ }

The tiny constant ε∼10−8\varepsilon \sim 10^{-8} prevents division by zero at t=0t = 0. Read coordinate by coordinate: parameters whose gradients have been large get a smaller effective LR; parameters whose gradients have been small keep a large effective LR. The total "amount of learning" per parameter is roughly equalised.

Intuition by dimension analysis: gtg_t has the same units as θ\theta per unit time. Gt\sqrt{G_t} also has units of θ\theta. The ratio gt/Gtg_t / \sqrt{G_t} is dimensionless, and α\alpha supplies the units of θ\theta. The update is unit-aware in a way plain SGD is not.


3. AdaGrad's failure mode

The sum Gt(i)G_t^{(i)} is monotonically non-decreasing: every step it picks up another (gt(i))2≥0(g_t^{(i)})^2 \ge 0. So the effective learning rate α/Gt\alpha / \sqrt{G_t} decays as Θ(1/t)\Theta(1/\sqrt{t}) in the worst case and never recovers.

For convex problems this is provably optimal (AdaGrad attains the optimal online regret bound for adaptive methods, see Duchi et al.). For deep nets, where you might need thousands of epochs and the optimal step size changes through training, AdaGrad shuts itself off before reaching a good solution. By the end of training, Gt\sqrt{G_t} is so large that no step makes meaningful progress, even when the loss landscape is begging for more movement.

This is the bug. The fix is to forget the distant past.[4, 5, 6]


4. RMSProp

Hinton (Coursera, 2012[2] — never formally published; the canonical reference is the lecture slides). Replace the cumulative sum with an exponential moving average:

 vt(i)=β2 vt−1(i)+(1−β2)(gt(i))2,θt+1(i)=θt(i)−αvt(i)+ε gt(i). \boxed{\ \begin{aligned} v_t^{(i)} &= \beta_2\, v_{t-1}^{(i)} + (1 - \beta_2)\bigl(g_t^{(i)}\bigr)^2, \\ \theta_{t+1}^{(i)} &= \theta_t^{(i)} - \frac{\alpha}{\sqrt{v_t^{(i)} + \varepsilon}}\, g_t^{(i)}. \end{aligned} \ }

This is the EMA from §3.2 applied element-wise to the squared gradient, then used as a per-parameter scale. Typical β2=0.99\beta_2 = 0.99 (Hinton's slides) or β2=0.999\beta_2 = 0.999 (the value Adam will inherit). The effective averaging window is ∼1/(1−β2)∼100\sim 1/(1-\beta_2) \sim 100 to 10001000 steps.

Because vtv_t is an EMA rather than a sum, the effective LR no longer decays to zero — it tracks the current variance of the gradient. If a parameter starts seeing smaller gradients, vtv_t adapts down, and the effective LR for that parameter goes back up. AdaGrad's monotonic decay is gone.


5. The geometric reading: a diagonal preconditioner

Both AdaGrad and RMSProp are instances of diagonal preconditioning. Let Dt=diag⁡(dt(1),…,dt(p))D_t = \operatorname{diag}(d_t^{(1)}, \dots, d_t^{(p)}) be a positive diagonal matrix. A preconditioned gradient step is

θt+1=θt−α Dt−1 gt.\theta_{t+1} = \theta_t - \alpha\, D_t^{-1}\, g_t.

For AdaGrad, dt(i)=Gt(i)+εd_t^{(i)} = \sqrt{G_t^{(i)} + \varepsilon}. For RMSProp, dt(i)=vt(i)+εd_t^{(i)} = \sqrt{v_t^{(i)} + \varepsilon}.

Choosing DtD_t correctly can dramatically reduce the effective condition number κ(Dt−1H)\kappa(D_t^{-1} H) — where HH is the Hessian — and therefore speed up convergence (compare with the κ\sqrt{\kappa} analysis of momentum in 3.3). A "perfect" Dt=diag⁡(H)D_t = \sqrt{\operatorname{diag}(H)} would diagonalise the per-coordinate scaling; what RMSProp uses is a cheap proxy: diag⁡(E[gg⊤])\sqrt{\operatorname{diag}(\mathbb{E}[g g^\top])}, the diagonal of the gradient covariance. For convex quadratics with diagonal HH, this proxy is right (because the gradient covariance is proportional to HH); for deep nets it is approximate but useful.

This is also the answer to the common question "why v\sqrt{v} and not vv?" — preconditioning a gradient step needs a length scale (dt∝d_t \propto standard deviation of gradient, not variance), and vt\sqrt{v_t} supplies it.[3]


6. Comparison to momentum

Momentum and RMSProp address different problems:

  • Momentum smooths over time, in the same direction for all coordinates. It accelerates along directions of consistent sign.
  • RMSProp rescales per coordinate, independent of sign. It equalises the magnitudes across coordinates.

They are complementary. Combine momentum's velocity mtm_t (EMA of gg) and RMSProp's scale vtv_t (EMA of g2g^2), use mt/vtm_t / \sqrt{v_t} as the update direction, and you get Adam — next session.


7. Practical defaults

For RMSProp:

  • α=10−3\alpha = 10^{-3}.
  • β2=0.99\beta_2 = 0.99 (Hinton's value; PyTorch default alpha=0.99).
  • ε=10−8\varepsilon = 10^{-8}.
  • No bias correction (you can apply the same 1/(1−β2t)1/(1 - \beta_2^t) trick from 3.2; some implementations do, most don't).

RMSProp was the workhorse adaptive optimiser from 2012 until Adam's paper in 2014. It is still used in RL (where Adam's momentum can fight policy updates) and in some image-generation pipelines.


8. Takeaways

  • AdaGrad: cumulative Gt=∑(gt)2G_t = \sum (g_t)^2; per-parameter LR α/Gt\alpha / \sqrt{G_t}. Provably optimal for convex problems; stalls in deep learning because GtG_t never decreases.
  • RMSProp: EMA vt=β2vt−1+(1−β2)gt2v_t = \beta_2 v_{t-1} + (1-\beta_2) g_t^2; same scaling but adaptive over a sliding window.
  • Both are diagonal preconditioners — they reshape the gradient by 1/coordinate variance1/\sqrt{\text{coordinate variance}}.
  • The \sqrt{} is not optional: it makes the units of the update match the units of θ\theta.
  • RMSProp + momentum → Adam (3.5).

Self-test

(a) On the elongated quadratic from 3.3, L=12(λ1θ12+λ2θ22)L = \tfrac{1}{2}(\lambda_1 \theta_1^2 + \lambda_2 \theta_2^2), what does the AdaGrad step do after one iteration starting at θ0=(1,1)\theta_0 = (1, 1)? Compute the rescaling factor for each coordinate and compare to plain GD.

(b) Show that on a stationary Gaussian gradient stream gt∼N(μ,σ2)g_t \sim \mathcal{N}(\mu, \sigma^2) (per-coordinate), the expected RMSProp scale E[vt]\sqrt{\mathbb{E}[v_t]} converges to μ2+σ2\sqrt{\mu^2 + \sigma^2}, i.e. the second moment of the gradient. Why ⋅\sqrt{\cdot} and not the variance directly?

(c) Argue that AdaGrad is bad when gtg_t is large at the beginning of training but small later — the typical "warmup" pattern. RMSProp handles this case gracefully; explain why.

(d) A "centred" version of RMSProp (used in some RL papers) tracks both the first moment mtm_t (EMA of gg) and second moment vtv_t (EMA of g2g^2) and uses vt−mt2+ε\sqrt{v_t - m_t^2 + \varepsilon} as the scale (i.e. the standard deviation, not the second moment). Explain in one sentence why this is the "more statistically correct" scale, and in one sentence why most implementations don't bother.


References

  1. [1]

    Duchi, J., Hazan, E., & Singer, Y. (2011). "Adaptive subgradient methods for online learning and stochastic optimization". JMLR, 12, 2121–2159. — AdaGrad (3.4).

    ↩
  2. [2]

    Hinton, G. (2012). "Lecture 6e: rmsprop — divide the gradient by a running average of its recent magnitude". Coursera: Neural Networks for Machine Learning. — RMSProp; never published as a paper, the slides are the canonical reference (3.4).

    ↩
  3. [3]

    Bishop, C. M. (2006). Pattern Recognition and Machine Learning, §3.4 and §5.5. — L2 as Gaussian prior / MAP (Appendix 3.A).

    ↩
  4. [4]

    Wenzek, G., Lachaux, M.-A., Conneau, A., et al. (2020). "CCNet: Extracting high quality monolingual datasets from web crawl data". arXiv:1911.00359 — Classifier-based filtering pipeline (7.1 §3.4).

    ↩
  5. [5]

    Gage, P. (1994). "A new algorithm for data compression". C Users Journal, 12(2), 23–38. — The original byte-pair encoding compression algorithm (7.2 §3.4).

    ↩
  6. [6]

    Narayanan, D., Shoeybi, M., Casper, J., et al. (2021). "Efficient large-scale language model training on GPU clusters using Megatron-LM". arXiv:2104.04473 — Interleaved pipeline + TP × PP × DP composition (7.9 §3.4).

    ↩