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 . 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 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 , keep a running sum of squared gradients
and use it to scale the step element-wise:
The tiny constant prevents division by zero at . 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: has the same units as per unit time. also has units of . The ratio is dimensionless, and supplies the units of . The update is unit-aware in a way plain SGD is not.
3. AdaGrad's failure mode
The sum is monotonically non-decreasing: every step it picks up another . So the effective learning rate decays as 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, 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:
This is the EMA from §3.2 applied element-wise to the squared gradient, then used as a per-parameter scale. Typical (Hinton's slides) or (the value Adam will inherit). The effective averaging window is to steps.
Because 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, 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 be a positive diagonal matrix. A preconditioned gradient step is
For AdaGrad, . For RMSProp, .
Choosing correctly can dramatically reduce the effective condition number — where is the Hessian — and therefore speed up convergence (compare with the analysis of momentum in 3.3). A "perfect" would diagonalise the per-coordinate scaling; what RMSProp uses is a cheap proxy: , the diagonal of the gradient covariance. For convex quadratics with diagonal , this proxy is right (because the gradient covariance is proportional to ); for deep nets it is approximate but useful.
This is also the answer to the common question "why and not ?" — preconditioning a gradient step needs a length scale ( standard deviation of gradient, not variance), and 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 (EMA of ) and RMSProp's scale (EMA of ), use as the update direction, and you get Adam — next session.
7. Practical defaults
For RMSProp:
- .
- (Hinton's value; PyTorch default
alpha=0.99). - .
- No bias correction (you can apply the same 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 ; per-parameter LR . Provably optimal for convex problems; stalls in deep learning because never decreases.
- RMSProp: EMA ; same scaling but adaptive over a sliding window.
- Both are diagonal preconditioners — they reshape the gradient by .
- The is not optional: it makes the units of the update match the units of .
- RMSProp + momentum → Adam (3.5).
(a) On the elongated quadratic from 3.3, , what does the AdaGrad step do after one iteration starting at ? Compute the rescaling factor for each coordinate and compare to plain GD.
(b) Show that on a stationary Gaussian gradient stream (per-coordinate), the expected RMSProp scale converges to , i.e. the second moment of the gradient. Why and not the variance directly?
(c) Argue that AdaGrad is bad when 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 (EMA of ) and second moment (EMA of ) and uses 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]
Duchi, J., Hazan, E., & Singer, Y. (2011). "Adaptive subgradient methods for online learning and stochastic optimization". JMLR, 12, 2121–2159. — AdaGrad (3.4).
↩ - [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]
Bishop, C. M. (2006). Pattern Recognition and Machine Learning, §3.4 and §5.5. — L2 as Gaussian prior / MAP (Appendix 3.A).
↩ - [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]
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]
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).
↩