TL;DR
Plain gradient descent steps directly downhill from where it stands, so it forgets everything it learned one step earlier. Momentum keeps a velocity: each step adds the new gradient to a decaying sum of past gradients and moves along that sum. Directions that keep agreeing gain speed, and directions that flip back and forth cancel out.
Where you'll see it: inside almost every neural network optimizer, usually as the first moment term of Adam or as the momentum setting of SGD in deep learning frameworks.
Intuition
A ball rolling downhill
Picture a ball rolling over a hilly landscape. Gradient descent is a ball with no mass: wherever the slope pushes it, it moves exactly that far and stops. A real ball has inertia. It keeps rolling in the direction it was going, and a small bump does not stop it. That inertia is momentum.
The gain is largest in badly shaped landscapes. Imagine a long, narrow valley that slopes gently towards its end but steeply across its width. Plain gradient descent points mostly across the valley, so it zigzags from wall to wall and crawls along the floor. The across-valley gradients point in alternating directions and cancel in the velocity sum, while the along-valley gradients all agree and add up. The ball therefore speeds up down the valley and stops bouncing off the walls.
This is why momentum was adopted so widely. Neural network loss surfaces have many such ravines, and an optimizer that zigzags wastes steps.
flowchart LR A[Current gradient] --> C[Velocity: decayed old velocity plus new gradient] B[Previous velocity] --> C C --> D[Move parameters by learning rate times velocity]
The math
Update rule
Let be the parameters at step , the learning rate, the momentum coefficient (commonly 0.9), and the gradient of the loss. The classical momentum update is
with . The velocity is a sum of past gradients, each multiplied by a power of :
So controls memory. A gradient steps old still counts, weighted by . Setting recovers plain gradient descent.
Relation to an exponential moving average
If you rescale the velocity as , the update becomes . Each is then an exponential moving average of the gradients. Many textbooks write momentum in this form, and Adam uses the same averaging for its first moment. The two forms differ only by a rescaling of the learning rate.
Effective step size
If the gradient stays at a constant value , the velocity grows towards
With the step is ten times as large as plain gradient descent in a consistent direction. That is the speed-up, and it is also the reason the learning rate often has to be reduced when momentum is turned on.
Worked examples
Minimise , so . Start at with learning rate .
Plain gradient descent, :
Momentum with , :
- Gradient . . .
- Gradient . . .
- Gradient . . .
Interpretation: after three steps plain descent is at 0.512, while momentum is at 0.062, closer to the minimum at 0. Both start with the same first step, and momentum pulls ahead because every gradient so far points the same way, so the velocity keeps growing.
Suppose the gradient is a constant at every step, with and .
The sequence climbs towards , and it takes roughly 20 to 30 steps to get most of the way there. Interpretation: the optimizer's step grows smoothly to ten times the plain step as long as the direction stays the same.
Tradeoffs and failure modes
Momentum is cheap, since it stores one extra vector per parameter, and it usually converges faster on ravines. It has failure modes too.
| Situation | Problem | Better choice |
|---|---|---|
| High with a large learning rate | The ball overshoots the minimum and oscillates, sometimes diverging | Lower , or use a smaller |
| Noisy stochastic gradients | Momentum smooths noise but can also carry a bad estimate for many steps | A larger batch size, or Adam's adaptive scaling |
| Narrow minima near the end of training | Leftover velocity keeps the iterate moving past the minimum, so the loss oscillates before settling | Learning rate decay, or a smaller late in training |
| Parameters with very different scales | One global velocity treats all coordinates alike | Per-parameter scaling, as in [[adam-optimizer |
Nesterov momentum is a common variant. It computes the gradient at the point the velocity is about to carry the parameters to, rather than at the current point, which corrects overshoot earlier. In practice the two perform similarly in deep learning.
History
Boris Polyak introduced the heavy ball method in 1964 as a way to speed up iterative methods for solving equations, using a term proportional to the previous step. Yurii Nesterov's 1983 accelerated gradient method gave a provably faster rate for convex problems, and its lookahead form became known as Nesterov momentum.
For neural networks the decisive study was Sutskever, Martens, Dahl and Hinton's 2013 paper on initialization and momentum in deep learning. They showed that carefully tuned momentum let deep networks train from scratch with first-order methods, which were then the standard option. Momentum has been part of nearly every training recipe since, and it is the ancestor of the adaptive optimizers that dominate today.
Check yourself
QuestionPlain gradient descent and momentum both start at the same point with the same learning rate. Why can momentum make progress when the gradient is almost zero in the current step?Show answer
The velocity is a decaying sum of past gradients, so the previous large gradients still move the parameters even when the current gradient is tiny. This is how momentum crosses flat regions and saddle points.
QuestionWith , what fraction of a gradient from three steps ago still contributes to the current velocity, relative to the newest gradient?Show answer
The contribution of a gradient steps old is weighted by . Three steps old gives , or one eighth of the newest gradient's weight.
QuestionFor and a constant gradient , what is the limiting velocity, and why might a learning rate that worked with now be too large?Show answer
The limit is , which is 100 times the plain gradient, and ten times the case. The step size scales with , so the learning rate usually has to shrink as approaches 1.
QuestionIn a long ravine, gradients alternate between pointing across the valley and along it. Explain in words why momentum helps along the valley and not across it.Show answer
The across-valley components flip sign each step, so they partly cancel in the sum of past gradients. The along-valley components keep the same sign and accumulate. The velocity therefore grows in the useful direction and shrinks in the oscillating one.
QuestionYou turn momentum on and the loss starts oscillating wildly and then increases. Name the most likely cause and the first change you would make.Show answer
The effective step has grown, because the velocity amplifies the learning rate, so the optimizer overshoots. The first change is to lower the learning rate, or to reduce if the learning rate is already sensible.
Sources
- Goh, Why Momentum Really Works, Distill (2017): https://distill.pub/2017/momentum/
- Gradient descent (Wikipedia): https://en.wikipedia.org/wiki/Gradient_descent
- Goodfellow, Bengio, Courville, Deep Learning (MIT Press), ch. 8: https://www.deeplearningbook.org/