Gradient descent, one step at a time
How a ball finds the bottom of a valley
The idea
Small steps beat big guesses.
The loop
- Measure the slope where you stand
- Take a small step downhill
- Repeat until the ground is flat
The valley
The update rule
\theta_{t+1} = \theta_t - \eta \, \nabla f(\theta_t)
Step against the gradient, scaled by the learning rate
In code
for step in range(200):
theta = theta - lr * grad(f, theta)
Small steps, flat ground. Questions?