Before you move a control in the demo, say what you expect to change.
Foundation reference
Stochastic Gradient Descent & Momentum
Stochastic gradient descent (SGD) steps against the gradient of the loss on a mini-batch; momentum steps against an exponentially weighted sum of past mini-batch gradients. SGD with momentum was the standard optimizer for image classifiers such as ResNet, which was trained with momentum 0.9 (He et al., 2016).
Study guide
Where to start
How does the velocity, an exponentially weighted sum of past gradients, average out mini-batch noise while adding up a direction that stays the same from step to step?
How to study this pagePredict · Check · Generalize · Continue
Compare what the demo shows with the key equation and with the papers cited below.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
Use the prerequisites and related concepts at the end of the page to fill the next gap.
Why It Matters for Modern Models
- Stochastic gradient descent (SGD) steps against the gradient of the loss on a mini-batch; momentum steps against an exponentially weighted sum of past mini-batch gradients. SGD with momentum was the standard optimizer for image classifiers such as ResNet, which was trained with momentum 0.9 (He et al., 2016).
- Adaptive methods such as Adam often reduce the training loss faster, but Wilson et al. (2017) found that on several benchmarks their solutions generalized worse than those found by SGD.
- For smooth convex functions with exact gradients, Nesterov's method reduces the error at rate O(1/k²) after k steps, against O(1/k) for gradient descent, which is the best rate any first-order method can guarantee on this class (Nesterov, 1983).
Questions to Think About
- In a long, narrow valley of the loss, why does momentum speed up progress along the valley floor while damping the zig-zag across it?
- Why does evaluating the gradient at the look-ahead point let Nesterov momentum correct a poor velocity sooner, making it more stable than classical momentum at high μ (Sutskever et al., 2013)?
Interactive Demo
Core Math
If you prefer intuition first, try the demo above, then come back for the math.
Stochastic gradient descent (SGD) steps against the gradient of the loss on the mini-batch :
Momentum (the heavy-ball method; Polyak, 1964) keeps a velocity , an exponentially weighted sum of past gradients:
Nesterov momentum evaluates the gradient at the point the velocity is about to carry the parameters to (Nesterov, 1983; Sutskever et al., 2013):
If the gradient stays roughly constant at , the velocity approaches , so each step approaches . With that is ten times the plain SGD step. Along directions where the gradient keeps changing sign, the contributions largely cancel instead.