Adam (Adaptive Moment Estimation) gives every parameter its own learning rate. It keeps two running averages of the gradient: the first moment (the mean — momentum) and the second moment (the mean of the squared gradient — à la RMSProp). Dividing the first by the root of the second normalizes each parameter's step by how big its gradients typically are. Large-gradient directions get reined in; small-gradient directions get amplified.
At step
Step 1 — the first moment (momentum). An exponentially-weighted average of the gradient:
Step 2 — the second moment (RMS). An exponentially-weighted average of the
squared gradient (element-wise
Step 3 — why the moments are biased. Both buffers start at
So
Step 4 — bias-correct. Divide out exactly that factor to recover an unbiased estimate:
As
Step 5 — the adaptive update. Step along the bias-corrected first moment,
scaled per parameter by the root of the bias-corrected second moment (with a tiny
The ratio is the magic: a parameter whose gradients are consistently large has large
Adam's adaptive per-parameter learning rates make it converge fast and reliably on almost any problem you throw at it — which makes it tempting to treat "use Adam" as a universal guarantee of the best possible result. It isn't.
Adam's speed and reliability are about how easily and quickly it gets to a good solution in practice, not about which solution it lands on. On some tasks — especially large vision models — a carefully tuned plain SGD with momentum, run for long enough, ends up generalizing better than Adam even though it converges more slowly. This is a real, actively debated area in machine learning research: there is no single optimizer that wins on every problem.
The practical takeaway is not "avoid Adam" — it is that "just use Adam" is an excellent default starting point, precisely because it is forgiving and rarely diverges, but it is not a promise that you have found the best optimizer for your problem.
Classic L2 regularization adds
AdamW fixes this by decoupling weight decay from the gradient: apply the adaptive step, then shrink the weights separately,
The decay now hits every parameter uniformly, independent of its gradient history. This small change measurably improves generalization, which is why AdamW is the default optimizer for training transformers and most modern large models.
The same elongated, ill-conditioned bowl, descended three ways from the same start: plain
For nearly all deep learning today, the answer to "which optimizer?" is Adam (or AdamW), and
the answer to "what tunes it?" is the