gradient descent
you're blindfolded on a hill.find the lowest point
you can't see a thing. all you can feel is the ground sliding away under your feet. tap where to step. you get 6 steps
- height
- 5.38
- steps left
- 6
height 5.38, 6 steps left. downhill is right and up.
that hill was a line
every spot on the hill is one line through these points. each square shows how wrong the line is about one point, and your height was their average size. shrink them
the hill is every possible line, and height is how wrong each one is
the line. drag its 2 handles
the same line, as a spot on the hill. drag the dot
tilt-0.60
height0.30
error5.38
this is the hill you were standing on. slide to look down from above
which way is downhill?
the model can't see this map. it can only nudge each number a tiny bit and feel whether the error drops. those nudges are called the gradient. guess first, then check
the gradient is which way the error rises. so you walk the other way
nudge the tilt: error changes by-0.065
nudge the height: error changes by-0.006
error5.38
tap around the dot: which way do you think is downhill?
every point gets a say
each point pulls the line toward itself, and the worse the miss, the harder the pull. add up all the pulls and you get the direction. drag a point
the direction comes from the data. the worst misses pull hardest
touch a part of the equation to see what it does
drag the points
what each point wants
where that sends the line
total6.46, 0.58
error5.38
point 5 is pulling hardest, with 44% of the pulling. touch the equation to see why
how big a step?
the direction says which way, not how far. too small takes forever. too big makes things worse with every step. this one setting matters more than almost anything
the gradient says which way. the step size decides if it works at all
every step, on the map
the error at each step
- step
- 0
- error
- 5.377
- step size
- 0.080
- the limit here
- 0.500
small steps. safe, and slow
what goes wrong
that bowl was friendly. real hills are messier, in 3 ways
flat doesn't mean finished, steep walls slow you down, and every step is a guess
when one direction is much steeper, you bounce between the walls instead of moving forward
steeper one way by50×
steps to reach the bottom49
the steep walls force tiny steps, so it bounces across and crawls forward
your turn
a new hill with 2 valleys, and the settings people really tune. drag the ring, turn the dials, or try a preset. the hill is made up. every step is real
every optimiser is a different answer to one question: how should i step?

calm and reliable, and it stops at the first bottom it meets. settled in the shallow valley, 1.32 above the deep one
hover or turn a dial to see what it does
height over time
so, what is gradient descent?
it's how a machine gets less wrong, one small step at a time
measure how wrong you are. find which way is less wrong. take a small step. repeat. that's how nearly every neural network on earth learns
step0
error5.377
the same bad line you started with, learning by itself. it gets to 0.076, the best any straight line can do