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
- Gradient descent without momentum fails in ravine-shaped landscapes because it discards all trajectory information. Each step is computed fresh from the local gradient. In a ravine with high curvature across the width and low curvature along the length, the across-ravine gradient is large and the along-ravine gradient is small — so each step takes a large oscillating step across the ravine and a tiny step forward. The optimizer zigzags.
- Momentum fixes this by accumulating velocity: v ← βv + ∇L(θ); θ ← θ − αv. The velocity is an exponential moving average of past gradients. Across the ravine, gradients alternate sign (+large, -large, +large) — they cancel in the moving average, reducing velocity in that direction. Along the ravine, gradients consistently point forward — they accumulate in the moving average, growing velocity in that direction. Oscillation dampens; forward progress accelerates.
- The effective step size with momentum is amplified in steady-state. When gradients consistently point the same direction, velocity converges to ∇L/(1−β). With β=0.9 and α=0.01, the effective learning rate is 0.01/0.1 = 0.1 — 10x larger than α alone. This is why adding momentum requires reducing the base learning rate: the same α now produces much larger effective steps.
- Nesterov momentum computes the gradient at the look-ahead position θ − αβv rather than at θ. Vanilla momentum applies the current velocity, then corrects based on the gradient at the new position — it overshoots, then corrects. Nesterov sees where it is going before committing to the full step, allowing it to brake early. The classical O(1/t²) accelerated-convergence guarantee (Nesterov, 1983) is proven for a momentum coefficient that increases toward 1 across iterations (e.g. β_k=(k−1)/(k+2)) — not for the fixed β=0.9 used throughout this module. The constant-β "Nesterov momentum" used in deep learning does not carry that formal guarantee, though it typically converges faster in practice near minima than plain momentum.
- Momentum helps escape saddle points. At a saddle point the gradient is exactly zero, so gradient descent stalls: θ ← θ − α·0 = θ. Momentum continues: θ ← θ − α·(βv + 0) = θ − αβv. The accumulated velocity from the approach to the saddle carries the optimizer through the zero-gradient region. Once past the saddle point, the gradient is nonzero again and normal optimization resumes. Note this θ − αβv is a different role than the Nesterov look-ahead point above, even though the algebra matches: here it is the actual (plain-momentum) parameter update, and it only collapses to this form because ∇L(θ)=0 at the saddle; Nesterov's θ − αβv is never itself the final update, only the point at which the next gradient is evaluated before the real step is taken.
- The β hyperparameter sets the effective memory window. β=0.9 gives a window of 1/(1−0.9) = 10 gradient steps — enough to smooth mini-batch noise without making the optimizer sluggish to landscape changes. β=0.99 gives a window of 100 steps, useful for very noisy gradient signals but slow to respond when the loss landscape changes character during training.
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
- Plain GD has amnesia: every step is computed fresh from the local gradient with no memory of where it came from, so it zigzags back and forth across ravine walls and stalls dead at saddle points where the gradient is zero.
- Momentum keeps a velocity — a running average of past gradients: v ← βv + ∇L(θ), then θ ← θ − αv. The optimizer carries momentum through the landscape instead of restarting from scratch each step.
- Oscillations cancel, consistent directions accumulate: across a ravine the gradient flips sign each step so the velocity contributions cancel and the zig-zag is damped; along the gentle floor the gradient is consistent so velocity builds and the optimizer speeds up.
- It amplifies the effective learning rate: at steady state velocity → ∇L/(1−β), so β=0.9 makes steps roughly 10× larger than plain GD — remember to *reduce* the base α to compensate or you'll overshoot.
- Nesterov momentum looks ahead — it evaluates the gradient at θ − αβv (where the velocity is about to carry it) and brakes *before* overshooting, typically converging faster in practice near minima than plain momentum (the classical O(1/t²) guarantee needs an increasing-β schedule, not the fixed β used here).
- Momentum escapes saddle points and plateaus: the accumulated velocity carries it straight through the flat zero-gradient region where plain GD freezes, turning a stall into a slowdown.
- β sets the effective memory window: β=0.9 averages ~1/(1−0.9) = 10 steps (smooths mini-batch noise, still responsive), β=0.99 ~100 steps (handles very noisy gradients but is slow to react when the landscape changes character).
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?
- `A) In the across-ravine direction, the gradient alternates sign each step (+large, -large, +large), overshooting side to side. Momentum's velocity v = β·v_prev + g_current sums these alternating terms, so the positive and negative contributions cancel each other — oscillation is damped instead of repeating at full amplitude.`
- `B) In the along-ravine direction, the gradient is small but consistently points toward the minimum. Because velocity accumulates gradients that agree in sign, these small consistent terms build up over successive steps, so the optimizer's forward speed along the valley floor steadily increases.`
- `C) Momentum fixes the ravine problem by computing a weighted average of the current gradient and all past gradients, which reduces the variance of the gradient estimate. The across-ravine direction has the highest gradient variance, so averaging is strongest there and smooths out the oscillation directly.`
- `D) Momentum fixes oscillations by adding a term proportional to the second derivative of the loss. Since the second derivative is large across the ravine and small along it, this curvature term cancels the mismatch and makes the landscape appear isotropic to the optimizer.`
Q2. Why does adding momentum require reducing the base learning rate α, and what is the formula for the effective learning rate in steady state?
- `A) Adding momentum requires reducing α because the velocity term introduces a delay in gradient application — the effective gradient at step t is an average of gradients from steps t, t-1, t-2, etc. This averaging means the optimizer is responding to a stale gradient, which requires a smaller step to stay within the convergence radius. The effective learning rate is α·(1−β) rather than α/(1−β).`
- `B) Momentum requires reducing α because it changes the loss surface seen by the optimizer. The velocity term effectively transforms the loss landscape by smoothing the curvature, which shifts the stability boundary for the learning rate. The new stability condition is α < 2·(1−β)/λ_max, so as β increases toward 1, α must be reduced proportionally.`
- `C) In steady state, velocity converges to v* = g/(1−β), so the update becomes θ ← θ − α·g/(1−β) — an effective learning rate of α/(1−β). With α=0.01, β=0.9: effective lr = 0.01/0.1 = 0.1, 10x larger than α alone. Using the same α as without momentum risks divergence near the stability limit, so α should be reduced by roughly (1−β) when adding momentum.`
- `D) Momentum does not require reducing α — this is a common misconception. The β parameter controls how much of the previous velocity is retained, not the effective step size. The effective learning rate remains α regardless of β because each gradient contributes proportional to (1−β) in the velocity update, exactly canceling the 1/(1−β) amplification from the accumulation.`
Q3. What is the difference between vanilla momentum and Nesterov momentum? In what scenario does the difference matter most?
- `A) Vanilla momentum and Nesterov momentum are mathematically identical — Nesterov's formulation is just a rearrangement of the vanilla equations that looks different but produces the same parameter updates at each step. The "look-ahead" framing is a pedagogical convenience, not a distinct algorithm. Any observed performance difference between them is due to implementation differences, not the algorithm itself.`
- `B) Vanilla momentum applies velocity at the current θ: v ← βv + ∇L(θ). Nesterov computes it at the look-ahead θ' = θ − αβv instead, seeing what the gradient looks like after the step. Vanilla overshoots and oscillates near minima; Nesterov brakes early, typically converging faster in practice near minima than vanilla momentum.`
- `C) Nesterov momentum differs from vanilla momentum by using a larger β value — typically 0.99 vs 0.9 — which extends the effective memory window. This longer memory makes Nesterov better at escaping ravines by smoothing over more historical gradient directions, while vanilla momentum's shorter memory is better near minima where the gradient changes rapidly.`
- `D) The key difference is that Nesterov momentum applies the velocity step and gradient step simultaneously, while vanilla momentum applies them sequentially. Nesterov is most beneficial in early training when the optimizer is far from the minimum and both the velocity and gradient are large — applying them together avoids double-counting the current gradient's contribution to the update.`
Q4. How does momentum help escape saddle points, and why can't plain gradient descent do the same?
- `A) Momentum helps escape saddle points by computing the gradient over a larger effective region of the loss landscape. By averaging gradients from multiple previous steps, momentum effectively samples the gradient at multiple nearby points simultaneously, making it more likely that at least one of those points has a nonzero gradient that points away from the saddle. Plain gradient descent only evaluates the gradient at a single point.`
- `B) Both momentum and plain gradient descent escape saddle points using the same mechanism — mini-batch gradient noise. The gradient is never exactly zero in practice due to stochastic mini-batching, so both methods escape saddle points equally well. Momentum provides no additional benefit for saddle point escape; its value is exclusively for accelerating convergence in ravine-shaped landscapes.`
- `C) Momentum escapes saddle points by computing a higher-order gradient approximation. The velocity term v = βv + g approximates the first time derivative of the gradient, giving the optimizer information about how the gradient is changing. At a saddle point, even though the gradient is zero, the gradient's time derivative (captured in the velocity history) is nonzero, providing a direction to move.`
- `D) At a saddle point the gradient is exactly zero, so plain GD is stuck: θ ← θ − α·0 = θ. With momentum, the velocity accumulated before reaching the saddle is nonzero, so the update becomes θ ← θ − α·(βv + 0) = θ − αβv — the optimizer carries through the flat region even though the current gradient gives no signal.`
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 →