Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.A heavy ball rolling downhill
Plain gradient descent forgets everything after each step. In a long, narrow valley it bounces from wall to wall and creeps along the floor. Momentum gives the optimiser memory, like a heavy ball rolling downhill. Pushes that keep pointing the same way add up into speed, and pushes that alternate cancel out, so the ball rolls along the valley instead of bouncing across it.
SGD with momentum is still the default optimiser for many vision backbones and detectors, and momentum is inside Adam, Nadam, LAMB and Lion. The same heavy-ball idea appears in control (a second-order filter on the gradient) and in fast iterative solvers. Knowing that β = 0.9 multiplies the effective step by ten prevents many unstable training runs.
- 1. Momentum helps most when gradients…
- 2. In a narrow valley, momentum reduces…
- 3. β = 0 gives…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Update (PyTorch form): v ← βv + g, then w ← w − ηv. Example: w = 1, v = 2, g = 1, η = 0.1, β = 0.5 gives v = 2 and w = 0.8.
- EMA form: m ← βm + (1 − β)g, then w ← w − η′m. It is the same algorithm with η′ = η/(1 − β).
- Effective learning rate: along a constant gradient, v → g/(1 − β), so each step tends to η/(1 − β): 10η for β = 0.9 and 100η for β = 0.99.
- Optimal heavy ball for a quadratic with curvatures in [μ, L]: η = 4/(√L + √μ)², β = ((√κ − 1)/(√κ + 1))², with κ = L/μ. For κ = 100: η = 4/121 and β ≈ 0.669.
- Rates: per-step contraction (κ − 1)/(κ + 1) for gradient descent and (√κ − 1)/(√κ + 1) for heavy ball. At κ = 100: 0.980 against 0.818, about 50 against 5 iterations per factor e of error reduction.
- 1. Effective learning rate for η = 0.01, β = 0.9?
- 2. Optimal heavy-ball contraction at κ = 9?
- 3. The EMA and PyTorch forms differ by…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Momentum in code
Exercise 1.
- The PyTorch and EMA forms of momentum produce identical trajectories when the EMA learning rate is η/(1 − β).
- Along a constant gradient, the step approaches η/(1 − β).
- The optimal contraction factors predict that heavy ball needs about √κ times fewer iterations: 500 against 15.8 per factor e at κ = 1000.
Practice.
- β = 0.9 is the standard default. When raising β, lower η to keep η/(1 − β) roughly constant.
- Weight decay is usually added to the gradient before the momentum update in SGD (coupled), unlike AdamW (E3-8).
- Momentum makes the optimiser’s state part of the model checkpoint; restarting without it changes the trajectory.
- Momentum amplifies instability: the stability limit for heavy ball on a quadratic is η·λ_max < 2(1 + β).
torch.optim.SGD(model.parameters(), lr=0.1, momentum=0.9, weight_decay=5e-4, nesterov=False)- 1. If you raise β from 0.9 to 0.99, keep the effective step by…
- 2. Heavy ball's stability limit on a quadratic is…
- 3. Momentum buffers should be…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why √κ. On a quadratic, each eigen-direction with curvature λ evolves by a 2×2 linear recurrence in (wₜ, wₜ₋₁). Choosing η and β so that the recurrence’s eigenvalues have equal magnitude √β for every λ in [μ, L] gives contraction √β = (√κ − 1)/(√κ + 1) per step (Polyak, 1964). That matches the lower bound for first-order methods on quadratics: momentum is optimal there, up to constants.
Beyond quadratics. Heavy ball is not guaranteed to accelerate on general smooth convex functions (Lessard, Recht and Packard (2016) gave counterexamples). Nesterov’s method (E3-3) is the one with provable acceleration.
With noise. When gradient noise dominates, momentum with parameters (η, β) behaves like SGD with step η/(1 − β): the momentum buffer is a low-pass filter on the gradient, and the stationary variance depends mainly on the effective step. Its advantage then shrinks to almost nothing. Its practical value in deep learning comes partly from the ill-conditioning it overcomes, and partly from allowing a larger effective step at the same stability.
- 1. Heavy ball was introduced by…
- 2. On general convex functions, provable acceleration belongs to…
- 3. Under dominant noise, momentum with (η, β) behaves like SGD with step…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Where momentum helps, and where it does not
History.
- B. Polyak (1964) introduced the heavy-ball method.
- D. Rumelhart, G. Hinton and R. Williams (1986) used momentum in backpropagation.
- I. Sutskever, J. Martens, G. Dahl and G. Hinton (2013) showed momentum and its schedule are crucial for deep networks.
- L. Lessard, B. Recht and A. Packard (2016) showed heavy ball can fail to converge on some convex functions.
Exercise 2. We use quadratics in 50 dimensions with curvatures spread from 1 to κ, comparing gradient descent with η = 2/(L + μ) against heavy ball with Polyak’s optimal η and β. The table counts iterations until the loss falls below 10⁻⁶ of its start.
| κ | gradient descent | heavy ball | optimal β |
|---|---|---|---|
| 10 | 29 | 14 | 0.270 |
| 100 | 302 | 53 | 0.669 |
| 1000 | 3122 | 193 | 0.881 |
Then, at κ = 100 with Gaussian gradient noise and the same effective step η/(1 − β) = 0.01, the mean loss over the last 1000 of 3000 steps was: β = 0: 0.149; β = 0.5: 0.135; β = 0.9: 0.132; β = 0.99: 0.132.
- The theory held exactly. Gradient descent’s iterations grew about tenfold per tenfold κ; heavy ball’s grew about 3.7-fold, close to √10 ≈ 3.2. At κ = 1000 momentum was 16 times faster.
- The optimal β rises toward 1 as κ grows (0.27, 0.67, 0.88), which is why β around 0.9 works for typical problems.
- With noisy gradients, momentum gave almost no advantage at the same effective step: the noise floors differed by at most about 12%. Momentum’s benefit is against ill-conditioning, not against noise.
Momentum in AI, robotics and aerospace
- Vision backbones and detectors (ResNets, YOLO variants) are commonly trained with SGD plus momentum 0.9 and a schedule.
- Model-predictive control and trajectory optimisation use accelerated gradient methods for fast convergence within a control cycle.
- Filtering view: the momentum buffer is a first-order low-pass filter on the gradient, a familiar object for control engineers.
References
- B. T. Polyak (1964). “Some methods of speeding up the convergence of iteration methods.” USSR Computational Mathematics and Mathematical Physics 4(5).
- I. Sutskever, J. Martens, G. Dahl, G. Hinton (2013). “On the importance of initialization and momentum in deep learning.” Proc. ICML.
- L. Lessard, B. Recht, A. Packard (2016). “Analysis and design of optimization algorithms via integral quadratic constraints.” SIAM Journal on Optimization 26(1).
- G. Goh (2017). “Why momentum really works.” Distill.