How Far to Step, and When to Stop — Learning Rates and Optimisation
Chapters 1 to 3 settled which way to move. Two things are left: how far to step each time (the learning rate) and when to stop.
They look like separate questions. Chapter 1 deferred the first and Chapter 2 the second, both to "Chapter 4". Arriving here, the two turn out to be two grips on the same knob — that is this chapter.
1. The learning rate has a ceiling
The update is
Watch what happens on the one-dimensional quadratic . With , one update is
It is simply multiplied by every time, so after steps it is . That heads for zero exactly when , i.e.
In several dimensions the sharpest direction decides (the largest eigenvalue of the Hessian). For nothing to diverge, . Cross it and that one direction is amplified until everything breaks.
Measured on from Chapter 0-2. The curvatures are and , so the ceiling is . Starting from , steps to get within radius 0.01 of the origin:
| steps | |
|---|---|
| 0.01 | 688 |
| 0.05 | 135 |
| 0.10 | 66 |
| 0.18 | 35 |
| 0.19 | 44 |
| 0.199 | 459 |
| 0.1999 | 4603 |
| 0.2 | never |
| 0.21 | diverges |
The best value sits well below the ceiling (0.18), and performance collapses as the ceiling nears: 459 steps at , 4,603 at . It becomes useless long before it falls off the cliff.
2. Why one step size cannot suit every direction
The same multiplies every direction, but curvature differs by direction. A direction with curvature is multiplied by each step.
- Raise and the sharpest direction starts oscillating at
- Lower and the flattest direction barely moves, at
The best is where those balance. Solving :
For the example, . Sweeping, the minimum came out at with 35 steps. Estimating the count from the contraction gives — matching the measurement.
is the condition number. The larger it is, the closer the contraction sits to 1 and the less progress any number of steps makes. What makes learning rates hard is not model size but .
3. Momentum — cancelling the back-and-forth
The zigzag is the component that reverses every step. Add the steps up and it cancels.
says how much of the previous direction to carry. Reversing components cancel; components that keep pointing the same way (down the valley) accumulate.
Measured on the same problem with fixed:
| 0 (none) | 0.5 | 0.9 | 0.95 | 0.99 | |
|---|---|---|---|---|---|
| steps | 135 | 59 | 92 | 160 | 678 |
turns 135 into 59. But past 0.9 it gets slower: carry too much and it cannot turn where it needs to, so it overshoots. As with the learning rate, more is not better.
4. Adam — a different step size per direction
The condition-number problem came from using one everywhere, so vary it: divide each coordinate by a running average of its squared gradient.
( correct the bias from starting at zero; the details are in the article.) Coordinates that fire often get a large and a shortened step; rarely-moving coordinates get a longer one.
It promises no speed, though. On the same problem:
| method | best setting | steps |
|---|---|---|
| gradient descent | 35 | |
| + momentum | 59 | |
| Adam | 90 |
Plain gradient descent wins here, because the curvature is known and can be chosen. Adam's worth is not speed but landing somewhere reasonable without tuning, on problems whose curvature you do not know. In deep models, where gradient magnitudes differ by orders of magnitude between layers, "reasonable without tuning" is what matters.
5. When to stop — the step count is capacity too
Chapter 2 listed early stopping among the remedies for overfitting, on the grounds that "the number of steps is a form of capacity." Here is the measurement.
Same data as Chapter 2 (, , 20 points, degree 15), running gradient descent with no regularisation at all:
| steps | train RMSE | test RMSE | |
|---|---|---|---|
| 10 | 0.4522 | 0.4468 | 1.07 |
| 100 | 0.2350 | 0.4575 | 2.67 |
| 1,000 | 0.1583 | 0.3224 | 4.45 |
| 1,370 | 0.1546 | 0.3140 | 4.74 |
| 10,000 | 0.1512 | 0.3320 | 5.38 |
| 100,000 | 0.1442 | 0.5057 | 11.06 |
| 300,000 | 0.1392 | 1.0069 | 20.76 |
Training error falls to the end; test error bottoms out at and climbs. The U-shape Chapter 2 produced by raising the degree appears here by raising the step count.
The right-hand column says why. grows the longer you run. Limiting the steps was limiting .
Applying L2 (Chapter 2, equation (3)) to the same data and sweeping :
| best setting | test RMSE | ||
|---|---|---|---|
| early stopping | 0.3140 | 4.74 | |
| L2 | 0.3068 | 4.53 |
The floors differ by 0.0072 and the values nearly agree. The knobs — a step count and a — have nothing in common, and they are doing the same thing.
A common misreading: "as long as it doesn't diverge, a bigger learning rate is faster"
Look again at section 1. The ceiling is .
| 0.18 | 0.19 | 0.195 | 0.199 | 0.1999 | 0.2 | |
|---|---|---|---|---|---|---|
| steps | 35 | 44 | 90 | 459 | 4603 | never |
The cliff is at , but performance starts falling from . does not diverge — it converges perfectly well — and takes 131 times as long as the best.
Equation (3) explains it. Raising drives the sharpest direction's factor toward (oscillation), and as the contraction approaches 1: it stops shrinking. The best is where oscillation and sluggishness balance, at — not at the ceiling.
Momentum has the same shape (section 3): best at , and 678 steps at . "As large as possible without diverging" is wrong for both knobs.
Exercises
The answers are folded away. Work them first.
Exercise 1. A problem with curvatures and . (a) The ceiling on . (b) The best . (c) The resulting contraction, and the steps needed to cut the error to .
Show the answer
(a) . The ceiling depends only on the largest curvature.
(b) , just under the ceiling. The larger the condition number, the closer the optimum sits to the ceiling — and the more a mistake costs.
(c) Contraction , and steps. Against the example (35 steps): ten times the condition number, about 6.6 times the steps. Condition number matters.
Exercise 2. You halve the learning rate. (a) In section 5's table, where does the test-error minimum move? (b) What happens to its height? (c) What follows from that?
Show the answer
(a) Roughly twice as many steps — it moves right. Each step covers half as much ground, so reaching the same place takes twice as many. Lower the figure's learning-rate slider and the left panel's minimum slides right.
(b) Almost unchanged. If you end up in the same place (the same ), the test error is the same.
(c) The learning rate sets how many steps, not where you land (in this setting). So you cannot substitute the learning rate for early stopping. Where to stop is a separate decision, made on validation data (Chapter 2).
Exercise 3. The loss keeps falling while the validation error starts rising. (a) What is happening? (b) Will lowering the learning rate fix it? (c) Name three things to do.
Show the answer
(a) Overfitting. Training loss falls to the very end (the left column in section 5), so watching training loss alone cannot show you this moment. Watch the direction of the validation error.
(b) No. The learning rate controls speed, not destination (Exercise 2). Lowering it takes you to the same place more slowly, and the point where validation turns up simply arrives later.
(c) ① Stop where validation bottoms out (early stopping) ② apply L2 or another regulariser ③ add data or lower capacity. As section 5 shows, ① and ② do nearly the same thing. ③ is the more reliable lever, per Chapter 2.
What this chapter does not say
- Stochastic (minibatch) gradients are not included. Every measurement here uses the full-data gradient. The minibatch noise measured in Chapter 0-3 () is often said to act as a regulariser in itself; that is not measured here.
- Learning-rate schedules (decay, warmup, one-cycle) appear only as "machinery for chasing a moving ceiling"; which to use when is not covered.
- Adam's bias correction, the role of , and its interaction with weight decay (AdamW) are left to the article.
- "Early stopping = L2" is not an exact identity. It is a classical correspondence under a quadratic approximation, and what the text shows is that one measured setting comes out close. Nothing here claims it holds unchanged for a nonlinear model.
- Every number was computed and checked (the learning-rate sweep against the theoretical , the 35 steps predicted from the contraction against the 35 measured, the momentum and Adam sweeps, the early-stopping trace and the L2 sweep, and the comparison of the two optima).
Comments
Sign in to comment