Momentum
Momentum updates a stored velocity and steps opposite that new velocity.
On this page 8 sections
- Overview
- Momentum gives an optimizer memory of earlier gradients
- For vector parameters, update each velocity coordinate first
- Stored history can outweigh the current gradient
- The gradient now points negatively, yet this example’s memory still points positively
- Key takeaway
- Sources & further reading
- Concept connections
01Momentum gives an optimizer memory of earlier gradients#
Momentum gives an optimizer memory of earlier gradients. Repeatedly aligned gradients can reinforce each other; gradients that alternate signs can partly cancel in that memory. The stored velocity is a running direction, and the parameter update uses its new value.
Momentum retains a velocity from previous gradients. Here we use this explicit convention:
This velocity adds g directly; there is no extra (1−β) multiplier.
With old velocity 4, β=0.5 and g=−1, the new velocity is 1. From θ=5 and η=0.2, the parameter becomes 4.8.
Using , let old velocity be 4, , and current gradient be . Retained history is 2; adding the new gradient gives velocity 1. With parameter 5 and rate 0.2, subtract to get 4.8. Using the old velocity would give a different update.
Use , . Given (θ,v,g,β,η)=(2, 4, 2, 0.5, 0.25). Find (v′,θ′).
Show answer and explanation
New velocity 4; parameter 1.
02For vector parameters, update each velocity coordinate first#
For vector parameters, update each velocity coordinate first. Then subtract the scaled new velocity from its matching parameter coordinate.
The learning rate scales the parameter step, not the stored velocity in this convention.
Use , . θ=, v=, g=, β=0.5, η=0.5. Find θ′.
Show answer and explanation
New velocity ; subtract η times it.
03Stored history can outweigh the current gradient#
Stored history can outweigh the current gradient. Momentum can therefore move with the current gradient on an individual step.
Read the stated recurrence before calculating: other momentum conventions scale their stored state differently.
Use , . (θ,v,g,β,η)=(4, 8, -1, 0.5, 0.5). Draft: θ must move against g. Compute θ′.
Show answer and explanation
Velocity 3 carries history; θ′=2.5.
04The gradient now points negatively, yet this example’s memory still points positively#
The gradient now points negatively, yet this example’s memory still points positively. Momentum can therefore disagree with the current gradient on an individual step. Different implementations define velocity differently, so begin with the recurrence supplied by the task.
Use the stated convention: update velocity first, then subtract the learning-rate-scaled new velocity.
- Compute a momentum update using a stated velocity convention.
Sources & further reading
- [1]D2L §12.6.1.3, equation12.6.5 ↗D2L §12.6.1.3, equation12.6.5 · Article