Gradient Descent
Nudging values downhill toward less error, one small step at a time
- Gradient descent moves a little at a time in whatever direction is downhill from right where you're standing.
- What moves is the model's huge collection of internal values, and what goes down is the error, a measure of how wrong the answers are.
- It never sees the whole landscape and leaps straight to the answer. It moves a step, checks again, and repeats that endlessly.
- The learning rate decides how big each step is; the optimizer decides the style of moving.
- It stops once the ground underfoot goes flat. That spot isn't guaranteed to be the lowest point around.
Contents
1The analogy
Drive into an underground parking garage and there are no windows, so you have no idea which level you're on. Doesn't matter — following the ramp downhill still gets you to a lower floor. You don't need to have seen a level sign anywhere. All you need is to feel which way the floor slopes right where you are.
Gradient descent moves the same way. The model checks which direction lowers the error from where it currently stands, and shifts a little that way. From the new spot, it checks the slope again and shifts a little more. Repeat that step hundreds of thousands of times and you end up far lower than where you started.
Once the ramp goes flat and there's nowhere left to go down, that's today's stopping point.
2In detail
What goes down is "how wrong"
In the garage, height goes down. In training, error goes down — a single number for how far the model's answer strayed from the correct one. A big number means you're still up top; a small one means you've come a long way down.
The dials that move this number sit inside the model: the values adjusted during training, the weights and biases attached to every connection. Turn one dial and the error nudges up or down a bit. Gradient descent is the act of turning all these dials, a little at a time, in whichever direction lowers the error.
A large model has anywhere from millions to hundreds of billions of these dials. That's like standing on a floor that can tilt in millions of directions at once — impossible to draw, but the math works the same no matter how many directions there are.
The slope is read from right underfoot
The model can't survey the whole landscape. All it can see is the slope at the exact spot it's standing on. Nudge one dial by a hair and check how much the error rises or falls; do that for every dial, and the whole bundle becomes the downhill direction from here.
The procedure that actually runs this calculation is backpropagation. Once an answer comes out, it takes the error and works backward through the layers, handing each dial its own share: "you, move this much this way." Gradient descent takes that direction and moves the values accordingly.
Seeing only what's underfoot is both a weakness and a strength. You'll never know for certain where the lowest point is far away. But you also never have to search the whole landscape, which is exactly what lets a single step get computed even with hundreds of billions of dials. Testing every possible spot one by one would mean training never even starts.
Step size and style are handled separately
Knowing the downhill direction doesn't settle how far to go. How much to move in one step is set separately, by the learning rate. Set it big and you descend fast, but you might sail past the bottom and climb the opposite wall; set it small and it's safe, but you can spend all day on the same floor.
The style of taking that step belongs to the optimizer. It speeds things up when the direction stays consistent, and it can size the step differently depending on the direction. Direction comes from gradient descent, size comes from the learning rate, and style comes from the optimizer.
Flat doesn't always mean bottom
Keep descending and eventually you hit a spot surrounded by uphill on every side. There's nowhere left to go down, so the steps stop. But that spot isn't guaranteed to be the garage's lowest floor — it could just be a shallow dip in the middle of some random level.
Training still tends to work out, because with enough dials, a spot that's uphill in every single direction at once turns out to be rare, and most stopping points are low enough to be useful. Splitting the data into small chunks helps too — the slope underfoot shifts slightly each time, which helps shake the model loose from a shallow dip.
3More precisely
Gradient descent updates each value a little at a time, moving opposite to the gradient — the derivative of the error function with respect to that value. The gradient is only accurate right at that point, so a big jump throws off the direction. That's why updates are small and frequent; each one is called a step. It's also worth knowing that the unit for counting steps and the unit for a full lap through the data aren't the same thing.
The comparison breaks down in places too. The garage floor stays fixed, but in training, the ground underfoot shifts slightly depending on which data the gradient was measured from. It's common to measure the gradient from a chunk of data rather than the whole set at once — the ground wobbles a bit in exchange for taking steps far more often. And while a garage clearly has an up and a down, the real landscape has millions of directions, which makes it far stranger than the hill most people picture. A driver can also stop the car and simply look around, but gradient descent never gets that luxury — the only information it ever has access to is the slope right under the current step.
4Try it yourself
5Common misconceptions
It's easy to think gradient descent always finds the best possible answer, but actually it commonly stops at some nearby low spot, and that spot is usually good enough anyway.
It's easy to think the error shrinks on every single step, but actually it wobbles up and down while trending downward overall.
It's easy to think gradient descent computes the answer directly, but actually it only points which way to go — the moving has to be repeated over and over.
7One-line summary
In shortGradient descent is the basic footwork of training: read the slope right underfoot, and take small steps toward less error.
Spotted an error or have a better analogy? Suggest an edit · Last updated2026-09-02