3.2.5 · D5Training Deep Networks

Question bank — Adam and AdamW optimizers

1,737 words8 min readBack to topic

Before you start, we build up the symbols so nothing below is a mystery.

The four objects this whole page revolves around:

  • — the EMA of : smoothed direction (momentum, Momentum and Nesterov Acceleration).
  • — the EMA of : smoothed magnitude per coordinate (the RMSProp idea).
  • — their bias-corrected versions (both EMAs start at , so early on they read too low; dividing by undoes that).
  • The update: .

The figures below make momentum, the magnitude divide, and the signal-to-noise picture visible before you meet the traps.

Figure — Adam and AdamW optimizers
Figure — Adam and AdamW optimizers
Figure — Adam and AdamW optimizers

True or false — justify

Adam uses a single global learning rate for all parameters
False. The scalar is shared, but dividing by gives each coordinate its own effective rate (Figure 2), so scales differ per parameter.
In steady state on a constant gradient , Adam's step size grows with
False. As , and , so the step — magnitude , totally independent of .
Momentum (the term) alone would already give per-parameter adaptive rates
False. Momentum only smooths direction (Figure 1); it is Momentum and Nesterov Acceleration. The adaptivity comes entirely from the (magnitude) term, the idea borrowed from RMSProp.
Bias correction changes the answer even after millions of steps
False. , so the correction factors and vanish; it only matters in the early steps when the EMAs are still crawling up from zero.
Setting turns Adam into plain SGD
False. Then , , so the step is — that's signSGD, not SGD. See Stochastic Gradient Descent.
AdamW and Adam+L2 are identical when
True. With (weight decay off) there is nothing to decouple, so both reduce to the exact same update. They differ only for .
The in the denominator exists purely to avoid dividing by zero
False. It also caps the maximum effective learning rate at and shapes the update when is tiny — it is a genuine hyperparameter (default ).
Adam's update is exactly invariant if you multiply every gradient by a constant
False in general, true only when is negligible. scales by and scales by , so is unchanged — but the fixed does not scale, so if is comparable to the invariance breaks (see Edge cases).

Spot the error

"Since tracks gradient variance, a coordinate with large should get a larger step to escape faster."
Backwards. Large means steep/noisy, so we divide by to take a smaller, more cautious step there (Figure 2).
"To add weight decay in Adam, just append to the loss gradient ."
That is Adam+L2, the buggy version: the then gets divided by , so high-gradient weights get less decay. AdamW keeps decay outside that division. See Weight Decay and L2 Regularization.
"Bias correction divides by ."
No — it divides by , with the exponent . At these coincide, but for larger they diverge; the form is what makes the correction shrink over time.
" estimates the mean squared gradient, which equals the variance of ."
Only if the mean gradient is zero. Recall , so mixes variance and squared mean. Relevant to Bias-Variance in Gradient Estimation.
"The first Adam step is small because is only ."
Wrong. Bias correction restores and , so the first step magnitude is exactly per coordinate, not small.
"In AdamW every weight shrinks by each step."
It shrinks by the factor , i.e. by amount . The learning rate multiplies the decay too, which is why decay must be re-tuned when changes.

Why questions

Why square the gradient for instead of taking ?
Squaring gives an EMA of , a clean, differentiable, always-non-negative magnitude/variance estimate. It is only unbiased after the bias correction — the raw reads too low early on. then recovers an RMS scale.
Why is interpreted as a signal-to-noise ratio?
is the mean gradient (signal), is its typical magnitude (signal + noise). Consistent directions give ratio (full step); noisy directions give ratio (tiny step) — see the red curve in Figure 3.
Why choose much closer to 1 than ?
The magnitude estimate should be smooth and stable over a long window (~1000 steps), so it uses a slow decay; the direction should react faster to genuine changes (~10 steps), so it uses a shorter memory.
Why does AdamW decouple weight decay rather than fix the L2 gradient by pre-scaling it?
Because to pre-scale correctly you'd need before computing it, a chicken-and-egg problem; decoupling sidesteps the adaptive machinery entirely and gives uniform, predictable shrinkage.
Why does Adam often converge faster than SGD early in training but sometimes generalize worse?
The magnitude normalization lets it move confidently through ill-scaled loss landscapes early, but that same normalization can overfit sharp minima — a reason plain Stochastic Gradient Descent with tuning still wins on some tasks.
Why can Adam's effective learning rate be interpreted as and how does that interact with a schedule?
Because the update is , the schedule scales on top of Adam's own per-coordinate adaptation; the two stack, so a warmup still helps even though Adam adapts internally. See Learning Rate Schedules.

Edge cases

What happens on the very first step if exactly?
Then , so and the update is (with the denominator is nonzero). No movement — Adam does nothing without gradient information.
A coordinate has far smaller than . What limits its step, and what happens to scale-invariance?
The denominator is dominated by , so the step — capped near . Here scale-invariance breaks: multiply gradients by and now scales by but the -dominated denominator barely moves, so the step scales by (SGD-like) instead of staying fixed.
Without bias correction, what goes wrong in the first ~100 steps?
(uncorrected) is far too small, so is huge and early updates explode or destabilize — exactly when training is most fragile.
A gradient is consistently zero for a while, then suddenly spikes. How does respond, and what does it do to the step?
lags because of its slow decay (), so for a few steps underestimates the spike and the step there is temporarily too large before catches up.
If you set but forget you also folded L2 into the loss, what double-counts?
Decay is applied twice — once (scaled) inside and once (uniformly) as the decoupled AdamW term — so weights shrink far more than intended and the model underfits.
As with fixed, what happens to the correction factor ?
It diverges toward infinity, meaning is almost entirely the (near-zero) initial average and needs enormous un-shrinking; this is why is kept well below 1.

Recall One-line self-test

Cover everything above and answer: In steady state, what determines Adam's step magnitude? Only (and ) — not the gradient size. Adam responds to direction consistency, not raw magnitude.