Gradient Descent
Intuition
Standing on a hillside in fog, you can feel which way is downhill under your feet. Take a step that way, feel again, repeat. That is gradient descent: follow the negative slope to reach a minimum.
Precise explanation
To minimise , start at and repeat
where is the learning rate. Stop when the step is tiny, , or after a maximum number of steps.
For , , so . The error is multiplied by each step:
- : → converges;
- : oscillates forever between two points;
- : → diverges.
flowchart LR
s[x_t] --> g["compute slope f'(x_t)"] --> u["x_{t+1} = x_t − η·f'(x_t)"] --> c{"|step| < tol ?"}
c -- no --> s
c -- yes --> d[return x]
Worked example
, , : error multiplier ; iterates 0 → 1.5 → 2.25 → 2.625 → … → 3.
Common mistakes
- Adding the gradient (
x + lr*g) — that climbs uphill. - Testing convergence on with a tolerance far smaller than the step can resolve.
- Looping forever without a step cap when the learning rate diverges.
Why this matters
Every neural network, logistic regression (ML-11) and federated client update (FL-06) is trained with a variant of this loop.
References
- Mathematics for Machine Learning — Marc Peter Deisenroth, A. Aldo Faisal, Cheng Soon Ong (Cambridge University Press) (
S009) - Dive into Deep Learning — Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola (
S013)