ML Systems Lab Open interactive version →
Intermediate 45 min read momentumnesterovvelocityoscillationbeta

Momentum

Velocity accumulation, Nesterov look-ahead, and escaping oscillation in ravines.

Gradient descent treats every step as independent — it computes the gradient at the current position, takes a step, then forgets everything that happened before. On a smoothly curved loss surface this works, but real deep network landscapes have ravines: narrow valleys where the curvature across the valley is much higher than the curvature along it. In a ravine, gradient descent oscillates. Each step overshoots across the narrow dimension while barely advancing along the valley floor.

The gradient alternates direction across the ravine at every step, so the optimizer zigzags instead of running forward.

The solution is to give the optimizer memory. Momentum maintains a velocity vector that accumulates the history of past gradients, governed by a momentum coefficient β (a hyperparameter, 0 ≤ β < 1, that sets how much of the previous velocity carries forward): v ← βv + ∇L(θ), then θ ← θ − αv. Gradients that consistently point the same direction accumulate into large velocity in that direction. Gradients that alternate direction — the oscillation across the ravine — partially cancel each other in the velocity and die out. The optimizer now runs along the valley floor rather than bouncing off the walls. A further refinement, Nesterov momentum, computes the gradient not at the current position but at the position you will be after applying the current velocity. This look-ahead avoids applying a correction that is already about to be corrected — it removes a systematic lag between where the optimizer is and where the gradient says to go.

Key points

Takeaway

Momentum was invented to fix gradient descent's amnesia. Without memory of where it came from, the optimizer zigzags in ravines and stalls at saddle points. Velocity accumulation dampens oscillations across high-curvature directions and builds speed along consistent-gradient directions — transforming a step-by-step random walk into a directed trajectory.

Recap

Check your understanding

Q1. A model trains on a narrow ravine loss landscape. Plain SGD oscillates and makes slow progress. Which two of the following correctly describe the mechanism by which momentum fixes this?

Q2. Why does adding momentum require reducing the base learning rate α, and what is the formula for the effective learning rate in steady state?

Q3. What is the difference between vanilla momentum and Nesterov momentum? In what scenario does the difference matter most?

Q4. How does momentum help escape saddle points, and why can't plain gradient descent do the same?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →