Bring the mental model from Gradient Descent; this page will reuse it instead of restarting from zero.
Optimization
SGD & Momentum: The Workhorses of Optimization
Why plain gradient descent is noisy, how momentum smooths and accelerates it, and why the same trick still sits under many modern optimizers.
Concept Structure
SGD & Momentum: The Workhorses of Optimization
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learning map
SGD & Momentum: The Workhorses of OptimizationConceptual Bridge
What should feel connected as you move through this page.
Why plain gradient descent is noisy, how momentum smooths and accelerates it, and why the same trick still sits under many modern optimizers.
The next edge should feel earned: use the demo prediction here before following Adam Optimizer.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
Stochastic gradient descent is the simplest training loop:
- look at a mini-batch,
- estimate the gradient,
- step downhill.
The problem is that mini-batch gradients are noisy. On a narrow ravine, SGD can spend many steps zig-zagging across the steep direction instead of making steady progress along the shallow direction you actually care about.
Momentum adds memory. Instead of trusting only the current gradient, you keep an exponentially weighted average of recent gradients and move using that average.
That does two useful things:
- it smooths noise across batches,
- it accelerates consistent directions, because repeated pushes in the same direction accumulate.
This is why momentum feels like a heavy ball rolling downhill: tiny bumps get averaged away, while persistent slope keeps building velocity.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be parameters at step , the gradient, the learning rate, and the momentum coefficient.
Plain SGD is
Momentum introduces a velocity variable:
If gradients point in roughly the same direction for many steps, then approaches a geometric sum:
So with , the effective step along a persistent direction can be about larger than plain SGD with the same nominal learning rate.
Nesterov momentum evaluates the gradient at a look-ahead point:
The mental model is: "if I keep moving this way, what slope will I see next?"
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
A = np.diag([1.0, 25.0]) # shallow in x, steep in y
theta0 = np.array([6.0, 6.0])
def grad(theta):
return A @ theta
def optimize(mu, lr, steps=60):
theta = theta0.copy()
v = np.zeros_like(theta)
for _ in range(steps):
v = mu * v + grad(theta)
theta = theta - lr * v
return theta
sgd = optimize(mu=0.0, lr=0.08)
mom = optimize(mu=0.9, lr=0.02)
print("SGD final theta :", np.round(sgd, 3))
print("Momentum final theta:", np.round(mom, 3))
The learning rate for momentum is smaller here on purpose: once gradients accumulate, the effective step can become much larger than the raw lr suggests.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
No interactive demo yet for this concept. A natural next step is a ravine visualization that overlays SGD and momentum trajectories while you change learning rate and .
No live visualization is registered for this concept yet.
The page still supports explanatory demo notes above; when a viz.tsx exists, it will render here without changing the route.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Why plain gradient descent is noisy, how momentum smooths and accelerates it, and why the same trick still sits under many modern optimizers.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change SGD & Momentum: The Workhorses of Optimization should make visible.
Visual Inquiry
Make the image answer a mathematical question
Why plain gradient descent is noisy, how momentum smooths and accelerates it, and why the same trick still sits under many modern optimizers.
Which visible object should carry the first intuition?
Pick the cue that should make SGD & Momentum: The Workhorses of Optimization easier to reason about before the page gives the answer.
Claim Review
Why plain gradient descent is noisy, how momentum smooths and accelerates it, and why the same trick still sits under many modern optimizers.
Source IDs and witness objects are attached for review; they are not proof by themselves.
Add source metadata before claiming support.
Use equation, code, and demo objects to check whether the source support is operational.
Source support candidates
No structured source note is attached yet.
Practice Loop
Try the idea before it explains itself
Why plain gradient descent is noisy, how momentum smooths and accelerates it, and why the same trick still sits under many modern optimizers.
Before touching the demo, predict one visible change that should happen in SGD & Momentum: The Workhorses of Optimization.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
SGD & Momentum: The Workhorses of Optimization
What is the smallest example that makes SGD & Momentum: The Workhorses of Optimization click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:optimization/sgd-momentum.
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - SGD & Momentum: The Workhorses of Optimization Object key: concept:optimization/sgd-momentum Context: Optimization Anchor id: concept/concept-notebook/optimization/sgd-momentum Open question: What is the smallest example that makes SGD & Momentum: The Workhorses of Optimization click without losing the math? Evidence to inspect: - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/optimization/sgd-momentum
concept:optimization/sgd-momentum