The Mathematics of Gradient Descent
What Momentum Multiplies Your Step Size By
Last timeWhy Descent Zigzags
Momentum is a geometric sum of past gradients. Working out what that sum converges to explains both why it helps and why it needs a smaller learning rate.
The last lesson diagnosed the problem. In a stretched bowl the sharp directions
reverse on every step while the flat direction keeps pointing the same way.
That suggests an obvious repair: instead of using the current gradient, use an
accumulation of the recent ones, so that the reversals cancel and the agreements
add up.
That is momentum, and it takes two lines.
- the gradient at the current point
- the velocity, an accumulation of every gradient so far
- the momentum coefficient, between zero and one, usually 0.9
- the learning rate, which now multiplies the velocity rather than the gradient
The physical name is a distraction. Unroll the recursion and the velocity is
just a weighted sum:
Every past gradient is present, discounted by raised to its age. With
a gradient from ten steps ago still carries about a third of its
original weight, and one from fifty steps ago carries half a percent. The
velocity is a memory roughly steps deep.
The lesson stops here
8 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents