Adam and Other Optimizers
Improved versions of gradient descent. Momentum keeps the ball rolling; Adam also gives each weight its own step size based on how large its gradients have been.
Also optimizers · momentum · RMSProp · AdamW · SGD with momentum · adaptive learning rate
Kingma and Ba, 2014
Plain gradient descent takes the same careful step every time. Momentum is like a ball that builds up speed downhill. Adam is a hiker who takes longer strides on gentle, consistent slopes and shorter ones on bumpy terrain.
Where it fits
+All relationships as a list
Is a kind of / part of
Siblings
Applies to
Try it
How it works
Plain gradient descent uses one learning rate for every weight and reacts only to the current gradient. Two ideas fix its main weaknesses:
- Momentum: keep a running average of recent gradients and step along it. Zig-zags across a narrow valley cancel out, while consistent downhill directions build up speed.
- Adaptive step sizes (RMSProp): keep a running average of each weight’s squared gradients and divide by its square root. Weights with large, noisy gradients take smaller steps; weights with tiny gradients take bigger ones.
Adam (2014) combines both, with a small correction for the first few steps when the averages are still near zero. In practice it trains most networks well with its default settings, which is why it became the default. AdamW fixes how weight decay (regularization) interacts with the adaptive steps and is the standard for Transformers.
The 3D widget lets you race plain gradient descent, momentum and Adam on the same landscape.
The math
With gradient , decay rates and learning rate :
Everyday use cases
- Case 01
Training language models
Large language models are typically trained with AdamW.
- Case 02
A sensible default
For a new neural network, Adam with its usual settings is a reliable first choice.
Strengths, weaknesses and when to use it
Strengths
- Works well with little tuning across many problems.
- Handles parameters whose gradients differ wildly in scale.
Weaknesses
- Stores two extra numbers per parameter, which costs memory in huge models.
- Plain SGD with momentum sometimes generalizes slightly better in vision.
When to use itAs the default optimizer for neural networks; AdamW for Transformers.
Compare with
Check yourself
- Q01
What does Adam adapt for each parameter?
Show answer
A: Its step size
- Q02
Why does momentum help in a long, narrow valley?
Show answer
A: It averages out the zig-zag across the valley and builds speed along it