Last lesson we said "the computer adjusts numbers until the error is small". How does it adjust them? The answer is gradient descent — walking downhill.
Imagine standing on a mountain in the dark and wanting to reach the valley. You cannot see, but you can feel which way the ground slopes. Strategy: take one small step in the steepest downhill direction, then repeat. In ML the "mountain" is the error surface (the loss), a "step" is a change to the model's numbers, and the slope is called the gradient.
The step size is called the learning rate. Too large and you jump over the valley and bounce back — the error oscillates. Too small and you take thousands of steps before arriving — training is slow. The skill you learn is picking a step size that fits.
When the error stops falling we say the model converged. The stopping point may be the deepest valley (global minimum) or just a small pit (local minimum). In real problems you help by trying different starting points and shrinking the steps near the end.
Play with the widget below: change the learning rate and watch the error curve. Note which rate makes the error fall fast and stay stable.
What to remember:
- Gradient descent = walking downhill on the error surface
- Learning rate too big → oscillation; too small → slowness
- Training is a loop: predict → measure error → adjust → predict again