Gradient descent by hand
Learning objectives
- Write one gradient-descent step and carry it out for two parameters
- Say why the learning rate must stay below and what is
- Explain why a long valley makes gradient descent slow at any stable rate
- Read what a rate past the limit does on a loss with plateaus
One Subtraction a Step
Gradient descent moves every parameter a step against its slope: , one subtraction a parameter a step. On Section 0.4's valley, one neuron's weight and bias on the Marmousi2 column, the rate is capped by the valley's steepest curvature: past the descent is thrown out of the valley, and below it the floor, which curves 413 times less, is crawled. From the seed's own random start, 200 steps at 10, 30 and 70 % of the limit end 254, 222 and 213 m/s RMS from the column, against the minimum's 211 m/s; only the last comes within 1 % of it, at step 168. At 150 % of the limit the first step throws the neuron onto the plateau, 843 m/s, and it never comes back.
A Step Written Out
The descent starts where the trained neuron's own run started, its seed's Glorot draw: , , 891 m/s RMS, not chosen near the minimum (it is 5.23 from it in and 4.19 in ). The output layer is held at the trained neuron's, as in Section 0.4. At step 0 the kernel's gradient is ; at 70 % of the limit, , the step is
That is all a step is; the work is in the gradient, which Section 0.6 builds by the chain rule. Plate (c) writes out any step you choose. The column is the window at x = 3600 m of the Marmousi2 model, a 2D acoustic, constant-density slice of a synthetic model, not field data; the start, the rates and the 200 steps are the book's own.
The Limit
Near the minimum the loss is close to a quadratic with curvatures and along its two principal directions (Section 0.4). A step multiplies the error along a direction of curvature by , so the steep direction shrinks only if , that is . Then the flat direction shrinks by a factor of at least a step, which here is more than 0.995: hundreds of steps to make progress along the floor. The steepest direction caps the rate, and the flattest sets the pace.
Four Rates
At 10 % of the limit, , the descent creeps down the wall and crawls along the floor: 254 m/s after 200 steps. At 30 %, 222 m/s. At 70 %, , it reaches the floor and moves along it fastest, 213 m/s, within 1 % of the minimum from step 168. At 150 %, , its first step carries it across the valley and out of it, onto the plateau where the neuron is off, 843 m/s RMS; there the slope is too small ever to bring it back. On a quadratic bowl a rate past the limit diverges; on a network's loss, with its plateaus, it can just as well stall.
Why Optimisers
Ruder (2016) surveys the gradient-descent variants and the challenges they meet, among them choosing the rate and the slow progress along ravines; momentum, Adam and L-BFGS, Section 0.8's optimisers, are answers to this valley. PINN losses, with several terms of very different curvature, are where the problem is worst (Part 3).
What Comes Next
Section 0.6 shows where the gradient in step (c) comes from: the chain rule, run backwards through the network.
References
- Ruder, S. (2016). An overview of gradient descent optimization algorithms. arXiv:1609.04747.