This Optimization concept is the current object: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
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.
Learner Contract
What this page should let you do.
2 prerequisites listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Claim review not recorded
No structured claim checks yet; source metadata is not enough to establish support.Metadata-derived; review may be AI-assisted. Not a human certification.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.
Prediction check: before revealing the trace, inspect the learning rate, momentum coefficient, and the persistent-direction scale eta/(1-mu) for the quadratic witness A=diag(1,25).
Commit to one regime: no-memory zig-zag, useful memory, or too much memory. Then reveal the plain-SGD and momentum paths, final losses, steep-axis sign flips, and velocity norm. The caveat is part of the lesson: momentum is the same memory mechanism whether it settles the ravine or overdrives past it.
Live Concept Demo
Explore SGD & Momentum: The Workhorses of Optimization
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what SGD & Momentum: The Workhorses of Optimization should make visible before reading the result.
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.
Source Grounding
Canonical references for the mechanism on this page.
Add source metadata before treating this page as source-grounded.
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