The Learning Rate and Convergence
The learning rate decides everything: too small and training crawls, too big and each step overshoots until the weights blow up. On a bowl-shaped loss each step multiplies the distance to the bottom by , so training converges exactly when that factor is smaller than in size.
What the symbols mean
- Learning rate
The step size.
- Curvature
L″, how sharply the bowl curves. Bigger λ means a narrower, steeper bowl.
- Weight after k steps
Measured from the bottom of the bowl.
What the symbols mean
- Starting weight
Where training starts, measured from the bottom.
What the symbols mean
- Condition number
How stretched the bowl is: steepest curvature over gentlest. Gradient descent needs roughly κ steps to make real progress.
Explanation
The learning rate is simply the size of the steps gradient descent takes, the in . (It's called a rate because it says how much of the gradient you move per step.) Anyone who has trained a network has seen it go wrong both ways: tiny steps and the loss barely moves for hours, huge steps and the loss shoots up to infinity. The formula looks technical, but it says something simple: every step multiplies your distance from the bottom by the same number, , where is your step size and is how sharply the bowl curves. If that number is between and , the distance shrinks to zero. If not, it grows. That's the whole story, and it's a geometric sequence you already know.
The simplest bowl. Near its minimum, any smooth loss looks like a parabola. That's the second-order Taylor approximation, , because the first-order term vanishes where the slope is zero. So let's study the parabola itself, with the bottom moved to : , where . Its gradient is , so the update is
The loss follows along: , shrinking by the factor per step.
Four kinds of behavior. Write for the factor. As you turn up , here's what happens:
- , so : the weight slides smoothly to the bottom from one side. A tiny makes close to , which is slow.
- , so : it lands on the bottom in one step. (That's the idea behind Newton's Method: divide by the second derivative.)
- , so : each step overshoots to the other side of the bowl, but by less than the step before. It converges while flipping sign every step.
- , so : each step overshoots by more than the distance it started from. The distance grows by every step, and training diverges. (At exactly it bounces between and forever.)
Where comes from. A geometric sequence goes to exactly when . Unpack the absolute value: . The right inequality says , so is positive. The left one says . Together, . Think about why the limit has in it: a sharply curved bowl has steep walls, so the same produces a bigger gradient and a bigger jump. The sharper the bowl, the smaller the step you can afford.
Many weights: the condition number. Now take two weights, . The gradient is , so each coordinate gets its own factor: is multiplied by and by . Here's the trouble. To keep the steep direction from diverging you need , and then the gentle direction shrinks by only per step, which is close to . Even the best compromise, , which makes both factors the same size, leaves
With that's , and it takes about steps to shrink the error by a factor of . With , a perfectly round bowl, one step does it. For a general quadratic loss , the 's are the eigenvalues of the Hessian : in the coordinates of its eigenvectors the bowl splits into independent one-weight bowls like the one above.
The picture to keep in mind is a long, narrow valley. The steep walls cap the step size, and with steps that small the walk along the gentle valley floor takes forever. Inputs on very different scales (a house's area in square feet next to its number of bedrooms) stretch the bowl exactly like this, which is one reason inputs get normalized. Momentum and Adam, later in this unit, are two more answers.
In practice. A real loss isn't one parabola; its curvature changes from place to place. So people try learning rates on a log scale (0.1, 0.01, 0.001), keep the largest one whose loss curve goes down steadily, and usually lower as training goes on.
A common mistake. It's tempting to think a bigger learning rate always trains faster. It does, up to . Past that the overshoot starts eating into the progress, and past it diverges. When a loss explodes to infinity, the gradient isn't wrong; the steps are too big.
See it
Worked examples
Run gradient descent on from with three learning rates, , and . Find the first three steps of each, and the range of that converges.
- 1
Find the curvature. Matching with gives ; equivalently .
For , find the largest stable learning rate, the best fixed learning rate and how many steps it needs to shrink the error by a factor of .
- 1
Read off the curvatures. The loss is a sum of two one-weight bowls with and , and its gradient is .
Practice
Type your answer and check it. Solve them all to complete the lesson.
Gradient descent runs on . What is the largest learning rate for which it still converges? (It converges for every below this value.)
Gradient descent runs on . Which learning rate reaches the bottom in exactly one step from any starting point?
Gradient descent runs on with . What does it do?
Gradient descent runs on with , starting from . What is ?
Gradient descent runs on with , starting from . After how many steps is first below ?
An engineer training a model notices that near the end, the loss gets multiplied by every step, with learning rate . Model the loss near the minimum as . Estimate the curvature , then the largest learning rate that would converge.
For , gradient descent uses the best fixed learning rate. By what factor does each step shrink the error?
A model predicts house prices from two inputs: the area in square feet (values around ) and the number of bedrooms (values around ). Gradient descent on its MSE is painfully slow. What's the most likely reason?
The hardest one here. Get it, and you've got this lesson.
Gradient descent runs on . Find the largest stable learning rate, the best fixed learning rate and the number of steps that best rate needs to shrink the error by a factor of .
Where it's used
The learning rate is the first setting anyone tunes when training a network, and a common recipe is a "learning-rate range test": raise a little every step and watch for the point where the loss stops falling and starts exploding, which is the edge seen in practice. Large models start with a short warmup at a small , run near the edge, then decay toward zero. Normalizing inputs and layers, which makes the loss bowl rounder, is the condition number idea put to work.