Lesson 9 of 12 9 min · 133 words
Stochastic gradient descent
Updating from one example at a time: cheap but noisy.
Stochastic gradient descent (SGD) uses the gradient of the loss on a single random example per step: . On average this equals the full gradient, so it points the right way in expectation.
Each step is times cheaper, so SGD makes progress long before full-batch GD has finished a single step. The price is noise: the loss zig-zags instead of falling smoothly.
The noise can help — it can bounce the parameters out of shallow local minima and saddle points — but near the end it stops precise convergence, so the learning rate is usually decreased over time (a learning-rate schedule).
Formula to remember
Gradient descent
Step against the gradient with learning rate η.
Quick check · +5 XP