Gradient descent: what 'learning' actually means
Every time an AI gets trained: voice assistants, photo search, chatbots, translation
What problem does it solve?
How can a computer tune millions of knobs to make its mistakes as small as possible?
The big idea
Picture the total error as a landscape of hills and valleys, where every position is a setting of the knobs. You're blindfolded on it, but you can feel which way the ground slopes under your feet. Take a step downhill, feel again, step again. That's all 'learning' is: measure the error, compute the slope (the gradient), nudge every knob a little in the downhill direction, and repeat millions of times. The step size matters: too small and you crawl, too big and you leap across the valley.
How it works, step by step
- 1. Start with random knob settings w.
- 2. Measure the error (the 'loss') on some examples.
- 3. Compute the gradient: how the loss changes as each knob is nudged.
- 4. Move every knob a small step against the gradient: w ← w − η·∇L.
- 5. Repeat until the loss stops dropping.
The key formula
- all the knobs (the 'weights'); big AI models have billions
- the loss: one number measuring how wrong the model is
- the gradient: the direction of steepest uphill, so we go the opposite way
- the learning rate: how big a step to take
How fast is it?
Each step needs the gradient, which backpropagation computes for about the cost of running the model a couple of times. Real training uses 'stochastic' gradient descent: estimate the slope from a small random batch of examples instead of all of them, which is noisy but much faster. Improved versions like Adam adjust the step size per knob.
Try it yourself
- For L(w) = w², the slope is 2w. Start at w = 10 with η = 0.1 and do three steps by hand. Now try η = 1.1. What happens?
- Why don't AI researchers worry about local minima as much as you might expect? (In millions of dimensions, there's almost always some direction that's still downhill.)
Fun fact
The method is over 175 years old: Augustin-Louis Cauchy described it in 1847, for calculating the orbits of celestial bodies. The newest AI runs on a 19th-century idea plus enormous computing power.