13.2 Faster Optimizers
Momentum, adaptive rates, and related tricks.
These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.
Figures and notes follow Géron, Hands-On Machine Learning; Deisenroth, Faisal, and Ong, Mathematics for Machine Learning; and Theodoridis.
1. Why bother
Training a large deep net with plain gradient descent is slow. A faster optimizer is a large speedup.
2. Momentum
Polyak, 1964. A bowling ball on a gentle slope: slow at first, then it picks up momentum until terminal velocity. Plain gradient descent ignores past gradients. If the local gradient is tiny, it crawls.
Momentum keeps a velocity . Subtract the local gradient (times the learning rate ) from ; add to the weights:
If , terminal velocity is ten times . Plateaus and some local optima are easier to leave. Without batch normalization, upper layers often see badly scaled inputs; momentum helps.
The ball can overshoot, come back, and oscillate. A bit of friction (the decay) damps that. Cost: one more hyperparameter. is a usual default and is almost always faster than plain GD.
3. Nesterov accelerated gradient
NAG measures the gradient slightly ahead, in the direction of the current momentum, not at the current :
The momentum vector usually already points toward the optimum, so the lookahead gradient is a better estimate.

4. AdaGrad
On a long thin valley, gradient descent dives down the steep walls, then creeps along the floor. AdaGrad scales down the gradient on the steep coordinates:
and are elementwise. accumulates squared gradients. (often ) avoids division by zero.
That is an adaptive learning rate: steep directions decay faster than gentle ones. Updates point more toward the global optimum, and needs less tuning.
On simple quadratics this works. On deep nets AdaGrad often stops too early: grows until the effective rate is essentially zero. Do not train a deep net with it. Know it so the later adaptive methods make sense.

5. RMSProp
AdaGrad remembers every squared gradient. RMSProp remembers a recent average, with exponential decay:
and the same update as AdaGrad. Typical .
6. Why not Hessians
Everything above uses first derivatives (Jacobians). Second-order methods use Hessians. For parameters you store on the order of Hessian entries per output, versus Jacobian entries. Deep nets have tens of thousands of parameters. The Hessian often will not fit in memory; computing it is too slow even when it does.
7. Learning-rate schedules
If is too small, you will get there, late.

One hunt: start large, divide by 3 until training stops diverging. You land near a rate that learns quickly and still converges.
Other schedules, with iteration and a scale :
| Schedule | Rule |
|---|---|
| Power | |
| Exponential | |
| Piecewise constant | e.g. for five epochs, then for fifty, … |
| Performance | Every steps, if validation error has stalled, multiply by (same idea as early stopping) |
Practice
-
If momentum uses , how does terminal velocity compare to a plain gradient step of the same ?
-
AdaGrad and RMSProp share an adaptive . What does RMSProp change so that training need not freeze?
-
Nesterov evaluates where, relative to ordinary momentum?