Why the learning rate can't be too big
Gradient descent on the simplest possible loss, with a slider, and the one line of algebra that explains when it blows up.
#ml#optimization#interactive
Every ML course tells you to “pick a small learning rate.” Here is the smallest example that shows why, and exactly where “small” ends.
The setup
Take the loss . Its gradient is , so one step of gradient descent with learning rate is
That’s it: every step multiplies by the same number . After steps,
Play with it
Drag the slider and press Run. Try , then , then , then .
step 0 · w = -4.0000 · f(w) = 16.0000
What you just saw
The whole story is the size of :
| behaviour | ||
|---|---|---|
| slides smoothly into the minimum | ||
| lands on the minimum in one step | ||
| overshoots and zig-zags, but converges | ||
| bounces between forever | ||
| each bounce is bigger: divergence |
So gradient descent converges exactly when , i.e. .
How this page is built
This post is an .mdx file. The math is plain $...$ / $$...$$ rendered by KaTeX at build time,
and the demo is a React component dropped in as an island:
import GradientDescent from '../../components/islands/GradientDescent.tsx';
<GradientDescent client:visible />
client:visible means its JavaScript only loads when you scroll to it. Everything else on the page is static HTML.