Training and optimization
AdaGrad, RMSProp, Adam, and Adaptive Updates
Understand what adaptive optimizers remember, why they often train quickly, and where coordinate-wise scaling can mislead.
By the end you can
- Describe first- and second-moment state in common adaptive optimizers
- Compare AdaGrad, RMSProp, and Adam at a conceptual and operational level
- Explain bias correction without treating it as a universal performance guarantee
- Diagnose sensitivity to epsilon, beta values, sparse gradients, and state resets
One global step size may fit coordinates poorly
An embedding row updated rarely can have a very different gradient history from a dense projection matrix. Applying the same raw scale to both may create slow or unstable learning.
Adaptive optimizers maintain coordinate-wise statistics and use them to rescale updates. Letting the optimizer do that changes both optimization dynamics and the meaning of the learning rate.
AdaGrad arrived in 2011, in the Journal of Machine Learning Research, from Duchi and colleagues. Its abstract makes an unusual promise: the adaptation “allows us to find needles in haystacks in the form of very predictive but rarely seen features”. Rarely seen features are exactly the embedding rows that a dense projection dwarfs.
Every mechanism in this lesson descends from that sentence. So does every failure mode in it. The statistics that find the needle also decide how far each coordinate may move next, from a history the optimizer has already recorded. The constants that set the length of that history are not standardised across libraries. Nor are they left at their published values by the systems you have heard of.
Adaptive scaling is a learned diagonal preconditioner built from gradient history.
Fast early loss reduction is not a universal generalization verdict
Adaptive methods often reach low training loss quickly. Whether that turns into better validation behaviour is not vaguely open. It is a published dispute, with named sides, that a reader can go and read.
One side built a counterexample rather than a benchmark table. Its abstract states: “We construct an illustrative binary classification problem where the data is linearly separable, GD and SGD achieve zero test error, and AdaGrad, Adam, and RMSProp attain test errors arbitrarily close to half.” On a binary problem, half is chance. The data was separable, so the information needed for zero error was there. The three adaptive methods did not use it. Wilson and colleagues took that to NIPS in 2017, together with several deep models on which the adaptive solutions generalised worse even when their training performance was better. They closed by recommending that “practitioners should reconsider the use of adaptive methods to train neural networks”.
The rebuttal is equally specific. Another group re-ran the comparison and reached the opposite verdict: “Despite conventional wisdom (Wilson et al., 2017; Balles & Hennig, 2017), we find that when carefully tuned, ADAM and other adaptive gradient methods never underperform MOMENTUM or SGD”. Choi and co-authors explain the reversal procedurally rather than mathematically. Wilson et al. “observed a ranking that, at first glance, contradicts the inclusion relationships … because they were not tuning enough of the hyperparameters”.
Both results stand. What is measured when an optimizer is declared better is partly the optimizer and partly the tuning protocol applied to it. The second half is usually the half that goes unreported.
Shoes that adjust cushioning for each footfall
Shoes that add cushioning where the shocks repeat, and take it away where movement stays gentle, spread one stride into different effective pressure across the sole.
All of that cushioning is built from shocks already absorbed. Coordinate-wise rescaling from history is exactly the trade: a direction that has been quiet for a long time gets treated as though it will stay quiet. RMSProp's decay constant is where that history length is set. It has a traceable origin, because RMSProp has no paper.
Its primary source is a lecture slide from 2012, in Hinton's Coursera course “Neural Networks for Machine Learning”. The title slide of Lecture 6e reads “rmsprop: Divide the gradient by a running average of its recent magnitude”. Three slides later, under “rmsprop: A mini-batch version of rprop”, the method is defined: MeanSquare(w, t) = 0.9 MeanSquare(w, t−1) + 0.1 (∂E/∂w(t))². The credit line reads “(Tijmen Tieleman, unpublished)”. The decay is 0.9. That is the number the method was announced with, and it was never peer-reviewed.
Keras 3 still ships rho=0.9, Hinton's exact constant, and names that lecture deck as its only reference — a single line reading “[Hinton, 2012]”. PyTorch ships alpha=0.99. The implied averaging horizon, 1/(1−decay), is 10 steps in one library and 100 in the other. Same name, same config field, a documented ten-fold departure from the method as it was first stated.
Adaptive methods normalize according to observed coordinates, not an invariant notion of distance.
Key idea
Epsilon is part of the update, not only a divide-by-zero patch
When the second-moment estimate is small, epsilon can dominate the denominator and determine the effective scale. Its effect depends on whether a framework places it inside or outside the square root.
Low precision and tiny gradients make this choice more visible. Record which optimizer you ran, from which library, and what its defaults were. Adam came with four published defaults, from Kingma and Ba at ICLR in 2015. The caption of Algorithm 1 states that “Good default settings for the tested machine learning problems are α = 0.001, β1 = 0.9, β2 = 0.999 and ϵ = 10−8”. PyTorch ships exactly those: lr=0.001, betas=(0.9, 0.999), eps=1e-08. Keras 3 keeps the betas and sets epsilon to 1e-07. It also documents that its epsilon is the paper's “epsilon hat”, not the one in Algorithm 1. The two constants divide by different quantities: the uncorrected second moment in one case, the bias-corrected one in the other.
A ten-fold difference between libraries is the small end of the range. The Inception-v3 ImageNet models, from Szegedy and colleagues at CVPR in 2016, were trained with RMSProp at ǫ = 1.0. The paper's “Training Methodology” section records it: “Our earlier experiments used momentum [19] with a decay of 0.9, while our best models were achieved using RMSProp [21] with decay of 0.9 and ǫ = 1.0.” That is eight orders of magnitude above the 10⁻⁸ default, in the configuration whose Table 3 entry reports 23.1% top-1 error. Choi and co-authors surveyed the published choices: “some notable papers tuned ϵ and selected values up to eight orders of magnitude away from the common defaults. Szegedy et al. (2016) used ϵ = 1 for RMSPROP; Liu et al. (2019) reported that their results were sensitive to ϵ and set ϵ = 10−6 for ADAM; Tan et al. (2019) and Tan & Le (2019) set ϵ = 10−3 for RMSPROP”, alongside a further tuned value of 1.5×10⁻⁴. Their conclusion: “Our results also confirm that the optimal value of Adam's ϵ is problem-dependent, so the onus is on empirical studies that fix ϵ = 10−8 to defend that choice.”
The betas travel too, and the systems that moved them are named. The Transformer was trained with a shorter second moment and a smaller epsilon: “We used the Adam optimizer [17] with β1 = 0.9, β2 = 0.98 and ϵ = 10−9.” RoBERTa arrived at the same beta and moved epsilon the other way. Its authors write: “We additionally found training to be very sensitive to the Adam epsilon term, and in some cases we obtained better performance or improved stability after tuning it. Similarly, we found setting β2 = 0.98 to improve stability when training with large batch sizes.” Table 9 of that paper records ǫ 1e-6, β1 0.9 and β2 0.98 for both RoBERTa-BASE and RoBERTa-LARGE. GPT-3 went shorter still. Brown and co-authors write that “To train all versions of GPT-3, we use Adam with β1 = 0.9, β2 = 0.95, and ϵ = 10−8”.
Run the horizon arithmetic on those published values, 1/(1−β2): 1,000 steps at the paper's 0.999, 50 at the Transformer's and RoBERTa's 0.98, 20 at GPT-3's 0.95. Four named systems, one optimizer name, second-moment memories that differ by a factor of fifty, and epsilons spread across nine orders of magnitude from 10⁻⁹ to 1.0.
Small constants can control whole parameter groups when gradient magnitudes are small.
Figure
Comparison
Three adaptive families with different memory behavior
The names conceal distinct accumulation rules. The step from AdaGrad's cumulative sum to the exponential average used by RMSProp and Adam is not only a change of memory length. It is where Adam's convergence guarantee broke.
That break has a date and a page. Section 4 of the ICLR 2018 paper that found the error states it plainly: “The proof in the original paper of ADAM erroneously assumes that Γt is positive semi-definite and is hence, incorrect (refer to Appendix D for more details).” Reddi and colleagues did not stop at the flaw in the argument. They also show that “ADAM can fail to converge to an optimal solution even in simple one-dimensional convex settings”. Theorem 1 formalises it with an explicit one-dimensional convex online problem on which Adam has non-zero average regret. It provably does not reach the optimum, on a problem a reader could draw on paper.
Their repair is already in the reader's code. torch.optim.Adam carries the flag `amsgrad=False`, documented by the PyTorch maintainers as “whether to use the AMSGrad variant of this algorithm from the paper `On the Convergence of Adam and Beyond`”. The default is off. The three columns below differ in what they remember. The flag is the scar left by what forgetting cost.
AdaGrad
Accumulates squared gradients throughout the run.
- Strength: sparse coordinates
- Effect: rates only shrink
- Risk: premature freezing
- State: cumulative magnitude
RMSProp
Uses a decaying average of squared gradients.
- Strength: adapts to changing scale
- Effect: forgets distant history
- Risk: implementation variation
- State: recent magnitude
Adam
Combines momentum-like first moments with RMS scaling.
- Strength: fast practical progress
- Effect: coordinate-wise normalization
- Risk: sensitive state interactions
- State: first and second moments
Visual
Two memories inside Adam
Adam combines direction memory with magnitude normalization. Both memories are tensors the size of the parameters themselves, and they are billed accordingly.
The Hugging Face Transformers documentation states the per-parameter price: “Optimizer states such as Adam store two extra tensors per parameter, the momentum and variance, which are both in fp32. That's an additional 8 bytes per parameter.” Mixed-precision weights cost 6 bytes per parameter, and the gradients 4. The optimizer state is the largest of the three.
The ZeRO paper derives the same accounting in 2020. Rajbhandari and colleagues at Microsoft count an fp32 copy of the parameters, the momentum and the variance at 4Ψ bytes each, so “Mixed-precision Adam has K = 12” and 16 bytes per parameter in total. Their worked example: “For a model such as GPT-2 with 1.5 Billion parameters, this leads to a memory requirement of at least 24 GB, which is significantly higher than the meager 3 GB of memory required to hold the fp16 parameters alone.” Eight times the weights, for two exponential averages.
- 01
Current gradient
The present batch supplies a noisy coordinate-wise direction.
- 02
First moment
An exponential average tracks recent signed gradients.
- 03
Second moment
An exponential average tracks recent squared gradients.
- 04
Bias correction
Early averages are adjusted for their zero initialization.
- 05
Scaled update
The first moment is divided by a root-second-moment term plus epsilon.
Steps
Audit an Adam configuration beyond its name
Two “Adam” runs can differ materially through defaults and state handling. The published record shows where: in the second beta (0.999, 0.98, 0.95), in epsilon (10⁻⁹ through 1.0), and in whether `amsgrad` was on. The five steps below are what makes a run legible to someone who was not present for it.
Steps 4 and 5 carry the weight. The moments are the 8 bytes per parameter that outweigh both the mixed-precision weights and the gradients, so their norms are worth watching. Losing them at a checkpoint is expensive. A resume that silently reinitialises them restarts the second moment at zero. That is the exact condition bias correction exists to handle at step one of training, and no longer expects at step one hundred thousand.
1. Record beta values
State the memory horizons for first and second moments.
2. Record epsilon placement
Verify the formula used by the actual library implementation.
3. Inspect parameter groups
Separate frozen, decayed, sparse, and newly initialized tensors deliberately.
4. Track state norms
Monitor moments and effective updates for representative modules.
5. Test resume behavior
Confirm buffers, step counts, and scheduler state survive checkpoint restoration.
Example
Where adaptive scaling often earns its complexity
These are tendencies rather than guarantees, and each one below is attached to the evidence in this lesson rather than to habit.
- Sparse embeddings: Rarely updated coordinates benefit from histories that differ from dense parameters — the case AdaGrad made in 2011 for finding “very predictive but rarely seen features”.
- Transformer training: Adam-family methods handle heterogeneous parameter scales and noisy sequence objectives effectively in many recipes. The Transformer, RoBERTa and GPT-3 each retuned β2 away from 0.999 rather than accepting the shipped default.
- Rapid prototyping: Broadly useful defaults can reach a working region before extensive optimizer-specific tuning; the fifteen-optimizer benchmark found that evaluating several optimizers at their defaults worked about as well as tuning one.
- Nonstationary objectives: Decaying moments can adapt when task mixtures or data phases change — the property Hinton's slide names, dividing the gradient by a running average of its recent magnitude rather than of all of it.
- Fine-tuning: Small parameter-group rates and adaptive scaling can support selective changes, provided weight decay is handled correctly and the 8 bytes per parameter of optimizer state are budgeted for.
The optimizer state that survives each batch
Compare time to a validation target, final decision metrics, sensitivity across seeds, and resource cost. That comparison has already been carried out at scale, in public. The answer is not a ranking.
Fifteen popular deep learning optimizers were benchmarked against each other across more than 50,000 individual runs, presented at ICML in 2021. The abstract reports: “While we cannot discern an optimization method clearly dominating across all tested tasks, we identify a significantly reduced subset of specific optimizers and parameter choices that generally lead to competitive results in our experiments: Adam remains a strong contender, with newer methods failing to significantly and consistently outperform it.” Schmidt and colleagues also found that evaluating several optimizers at their defaults worked about as well as tuning a single one.
The same structural conclusion comes out of a different set of experiments. Choi and co-authors write that “we demonstrate the sensitivity of optimizer comparisons to the hyperparameter tuning protocol”, and put it more sharply still: “the hyperparameter search space may be the single most important factor explaining the rankings obtained by recent empirical comparisons in the literature”. A default-versus-default run does not measure two optimizers. It measures two search spaces that somebody else chose. One of them was Hinton's 0.9 in 2012; the other was rounded to 0.99 by a library.
Optimizer comparisons require matched tuning effort and evidence, not brand loyalty.
Key takeaways
- Adaptive optimizers rescale coordinates using gradient-history statistics, changing the interpretation of a global learning rate — the property AdaGrad sold in 2011 as finding needles in haystacks.
- AdaGrad accumulates magnitude permanently, RMSProp forgets older scale, and Adam combines first- and second-moment estimates; RMSProp's own decay of 0.9 comes from Hinton's 2012 lecture slide, and PyTorch's alpha=0.99 is a ten-fold departure from it.
- Bias correction compensates for zero-initialized moment estimates but guarantees nothing: Reddi and colleagues showed at ICLR 2018 that Adam's convergence proof is incorrect and that it fails on a one-dimensional convex problem, which is why `amsgrad` exists.
- Epsilon is a tuned hyperparameter, not a divide-by-zero guard: Inception-v3 used ǫ = 1.0 and the Transformer used ϵ = 10−9, eight orders of magnitude apart, and its placement differs between PyTorch and Keras 3.
- Optimizer state is the biggest buffer in the run at 8 bytes per parameter — at least 24 GB for GPT-2's 1.5 billion parameters against 3 GB of fp16 weights — so moments, step counts and parameter groups belong in a resumable experiment record.
- Fifteen optimizers over more than 50,000 runs produced no dominant method, and rankings reverse with the hyperparameter search space alone, so judge optimizers with matched tuning, seeds and budgets rather than defaults.