Trace the saved gradient sum from startup to steady behavior, then change history length and learning-rate placement.
ConceptCore MLTraining & research
Published ·8 min read·Core·Intermediate
Visual quick review
Compare raw SGD with momentum on an alternating gradient sequence and explain how momentum amplifies the consistent component while reducing the relative cross-valley oscillation.
Learning objective
In this recurrence, momentum reinforces persistent motion and damps alternating motion
Read it this way:Each step keeps part of the previous velocity and adds the current gradient. Repeated gradients reinforce that retained motion. Alternating gradients push against it, so much of their movement cancels. Momentum favors persistence, not every large individual gradient. Which sequence reinforces the same direction when half the previous velocity is retained?
Sources and provenance
Full explanation 8 min read
Summary
Momentum saves a decaying sum of gradients and uses it to choose the next parameter step.
It is useful when successive gradients contain persistent direction, but history can also delay a necessary reversal.
Task: filter four prescribed descent directions (1,2),(1,−2),(1,2),(1,−2) with retention β=1/2 and learning rate η=1.
Start the parameter and buffer at zero.
What changes relative to ordinary SGD?
Write gradient gt, descent direction dt=−gt, gradient buffer vt, and descent buffer ut=−vt.
The figure shows the warmed-up response, not the first four updates from zero.
These are prescribed inputs, not gradients reevaluated along two measured optimization trajectories.
Learning objective
Trajectory comparison: persistent versus alternating gradient components
use the same axes in both panels. Raw SGD follows descent directions dt = −gt = (1, ±2). Each step moves forward by 1 and across the valley by 2. With ut = 0.5ut−1 + dt after warm-up, the alternating steady-state updates are (2, ±4/3). The consistent component doubles; the cross-valley-to-forward ratio falls from 2 to 2/3. This is a filter response, not evidence of measured convergence. Compare learning rates as well as paths. This original trace was checked against Polyak (1964), Sutskever et al. (2013), and the PyTorch SGD definition.
Check: Why is the persistent component amplified while the alternating component is damped in this specific warmed-up recurrence?
Reference drawing
Learning objective
In this recurrence, momentum reinforces persistent motion and damps alternating motion
Derivation
use the same axes in both panels. Raw SGD follows descent directions dt = −gt = (1, ±2). Each step moves forward by 1 and across the valley by 2. With ut = 0.5ut−1 + dt after warm-up, the alternating steady-state updates are (2, ±4/3). The consistent component doubles; the cross-valley-to-forward ratio falls from 2 to 2/3. This is a filter response, not evidence of measured convergence. Compare learning rates as well as paths. This original trace was checked against Polyak (1964), Sutskever et al. (2013), and the PyTorch SGD definition.
Check: Why is the persistent component amplified while the alternating component is damped in this specific warmed-up recurrence?
Read it this way:Each step keeps part of the previous velocity and adds the current gradient. Repeated gradients reinforce that retained motion. Alternating gradients push against it, so much of their movement cancels. Momentum favors persistence, not every large individual gradient. Which sequence reinforces the same direction when half the previous velocity is retained?
Start from zero
Compute ut=βut−1+dt, then θt=θt−1+ηut:
Step
dt
ut
θt
1
(1,2)
(1,2)
(1,2)
2
(1,−2)
(3/2,−1)
(5/2,1)
3
(1,2)
(7/4,3/2)
(17/4,5/2)
4
(1,−2)
(15/8,−5/4)
(49/8,5/4)
Ordinary SGD ends at (4,0); the startup momentum path ends at (6.125,1.25).
The warmed-up figure instead ends at (8,0).
For constant input a, the limiting buffer solves u=βu+a, giving a/(1−β).
For alternating input +a,−a, let the positive-phase limit be b.
Then b=β(−b)+a, so b=a/(1+β).
Here the steady components are 2 and ±4/3.
Two formulations
Classical momentum (Polyak, 1964)
gt=∇L(θt−1),vt=βvt−1+gt,θt=θt−1−ηvt.
Assume 0≤β<1, zero initial buffer, and no dampening.
Expanding the recurrence gives vt=∑j=1tβt−jgj.
This is a decaying sum, not a normalized exponential moving average.
For the average mt=βmt−1+(1−β)gt, matching initialization gives mt=(1−β)vt.
An update using mt needs learning rate η/(1−β) to match the sum-based update at constant β.
Nesterov momentum (Nesterov, 1983)
New task: evaluate the gradient at a lookahead point.
Replace gt above with ∇L(θt−1−ηβvt−1); keep the parameter update based at θt−1.
Check: for L(θ)=θ2/2, current θ=2, previous v=1, η=0.1, and β=0.5, lookahead is 1.95.
The new buffer is 2.45 and parameter 1.755, versus classical 2.5 and 1.75.
Use when: the specified algorithm calls for lookahead; this is not merely a changed label on the same gradient.
Picking β
New task: respond faster when older directions become stale.
Reduce β and reconsider the learning rate together.
Check: constant gradient one gives limiting buffers 10 at β=0.9 and 2 at β=0.5.
At learning rate 0.1, limiting step magnitudes are 1 and 0.2.
Using 0.02 with β=0.9 matches the latter scale, but not its response speed.
Use when: history length changes; equal learning rates do not isolate smoothing.
Change the learning-rate placement
New task: resume across a learning-rate reduction from 0.1 to 0.05.
With vold=2, g=1, and β=0.5, the gradient buffer stays 2; the new step magnitude is 0.1.
The stored gradients do not contain the old learning rate.
For a displacement buffer pt=βpt−1+ηtgt, old p=0.2 instead gives pt=0.15.
Use when: resuming or translating implementations; preserve state according to the actual recurrence, not a universal reset rule.
Failure and transfer
Reconstruct: why is (2,±4/3) not the zero-buffer startup trace?
Answer
Those values solve steady-state equations after transients decay.
The four-row ledger retains the missing initial history explicitly; its final parameter differs from the warmed-up figure.
When SGD+momentum vs. Adam
Momentum changes the history filter; Adam also tracks coordinatewise squared gradients.
Neither mechanism establishes a universal speed or generalization ordering.
Compare tuned learning rates, schedules, regularization, stopping criteria, compute budgets, and repeated seeds on the target workload.
The scale 1/(1−β) is a useful history horizon, not an exact count of equally weighted observations.
For independent scalar gradient noise of variance σ2, the stationary sum has variance σ2/(1−β2).
The normalized average instead has variance σ2(1−β)/(1+β).
These noise assumptions do not describe every minibatch process.
Common pitfalls
A zero buffer creates startup transients, not an error that every momentum implementation must bias-correct.
A zero current gradient does not imply a zero update while history remains.
Larger retention can amplify overshoot as well as persistent progress.
Frameworks differ in dampening, first-buffer initialization, Nesterov parameterization, and learning-rate placement.
Algebraically related Nesterov forms require matching state definitions and schedule assumptions before comparing saved buffers.
Resume checkpoints must preserve parameters, optimizer buffers, step count, schedule state, and any random or sampling state needed for replay.