Momentum and stochastic-gradient updates in deep learning

← Back to Blog & Articles

Plain gradient descent updates w ← w - η∇J(w) using the full dataset's gradient at every step — infeasible for datasets with millions of examples.

Plain gradient descent updates w ← w - η∇J(w) using the full dataset's gradient at every step — infeasible for datasets with millions of examples. Stochastic gradient descent (SGD) instead estimates the gradient from a small random mini-batch, trading a noisier gradient estimate for a drastically cheaper per-step cost; the noise is not purely a downside; it can help escape shallow local minima and saddle points that full-batch gradient descent would follow exactly.

Momentum accumulates a running average of past gradients, damping oscillations in directions of high curvature (e.g., a narrow ravine in the loss surface) while accelerating movement in consistent directions:

v ← βv + ∇J(w), w ← w - ηv

With β typically 0.9, the effective step size in a direction with a persistent gradient grows toward η/(1-β) — a 10x amplification at β=0.9 — while gradients that oscillate in sign (high-curvature directions) partially cancel across the running average, damping oscillation.

Nesterov accelerated gradient (NAG) evaluates the gradient not at the current point w but at the point momentum is already about to carry us to, w - βv — a "look-ahead" correction that, informally, lets the optimizer respond to how the loss surface curves ahead of its current trajectory rather than only reacting after overshooting.

Continue with the book

Explore the full treatment, worked examples, and exercises in The AI Algorithms Compendium.


Companion article for The AI Algorithms Compendium, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top