Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Ask a few, not everyone
To find which way a crowd of a million people wants to move, you could poll everyone, which is slow and exact, or ask 32 random people, which is quick and roughly right. Repeating the quick poll many times and taking a small step each time gets you there far faster overall. Each step is a little wrong, but the errors average out.
That’s stochastic gradient descent: estimate the downhill direction from a small random mini-batch of data, step, and repeat.
Every neural network, from perception models on rovers to large language models, is trained with SGD or a variant. Choosing the batch size, step size and schedule determines training time, cost and even how well the model generalizes.
- 1. SGD estimates the gradient from…
- 2. Each SGD step is…
- 3. Over many steps, the errors in SGD's gradient estimates…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.The setting
Empirical risk: .
- Full gradient costs sample gradients.
- Mini-batch gradient: with a random batch of size .
- It’s unbiased: .
- Its covariance is , where is the per-sample gradient covariance.
The update
In practice: shuffle the data each epoch (one pass) and take steps per epoch.
- 1. The mini-batch gradient is…
- 2. Its variance scales as…
- 3. An epoch is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.Constant vs decaying steps
With a constant step, SGD converges quickly at first, then stalls in a noise ball: the steady-state error is for -strongly convex problems. Halving or quadrupling shrinks the ball.
To converge exactly, the steps must decay. The Robbins–Monro conditions are (enough total movement) and (the noise dies out). With , that means .
Rates (convex, bounded variance)
- Strongly convex, : .
- Convex, : .
That’s slower per step than GD, but each step costs instead of . For large , SGD wins per unit of compute. Proofs are in A6.3-2.
Practical choices
- Batch size: larger means less noise and better hardware parallelism, but beyond a critical batch size returns diminish (McCandlish et al., 2018).
- Linear scaling rule: multiply by when is multiplied by , with a warmup (Goyal et al., 2017).
- Shuffling (sampling without replacement) usually beats sampling with replacement.
- Generalization: SGD’s noise biases it toward flatter minima, a form of implicit regularization (Keskar et al., 2017).
- 1. With a constant step, SGD on a strongly convex problem…
- 2. Robbins–Monro steps ηₖ = c/kᵖ need…
- 3. The linear scaling rule says, when B doubles…
Level 3: Advanced
★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.Unbiasedness and variance
With drawn uniformly, . With i.i.d. draws (with replacement), the variance of an average of independent terms is . Without replacement it’s , which is zero at . ∎
The noise ball for a 1-D quadratic
Take with gradient noise of variance : . The stationary variance satisfies , so
It’s proportional to the step size and to the noise variance . ∎
Why steps must decay
If , the accumulated noise has unbounded variance. If , the iterates may stop short of the optimum. Robbins and Monro (1951) proved almost-sure convergence under both conditions.
Exercise 3.1: Stationary variance for η = 0.1, μ = 1, σ² = 1
. Halving to 0.05 gives , about half.
- 1. Without replacement, the batch-mean variance at B = n is…
- 2. The stationary variance of constant-step SGD on a quadratic is about…
- 3. If Σηₖ < ∞, SGD may…
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Training a terrain classifier on a fixed compute budget
A rover classifies terrain (safe vs hazardous) from 8 IMU/camera features using logistic regression on 20,000 labelled samples. Give each method the same budget: 40,000 per-sample gradient evaluations, two passes’ worth. Full-batch GD gets two steps and has barely moved. Mini-batch SGD (B = 32) gets 1250 steps and lands within about 0.002 of the optimal loss. When data are plentiful and redundant, SGD wins per unit of compute. That’s the foundation of all large-scale ML (Bottou and Bousquet, 2008).
SGD in AI, robotics and aerospace
- Deep learning at every scale: SGD with momentum and Adam (A6.3-3, A6.3-4) train perception, control and language models.
- Online learning on robots: adaptive control and system identification update parameters per measurement, SGD-style (LMS; Widrow and Hoff, 1960).
- Large-batch training across GPU/TPU clusters relies on the linear-scaling and warmup rules (Goyal et al., 2017; You et al., 2020, LAMB).
- Stochastic approximation underpins TD learning and Q-learning in RL (Sutton and Barto, 2018).
References
- H. Robbins, S. Monro (1951). “A stochastic approximation method.” Annals of Mathematical Statistics, 22(3).
- L. Bottou, O. Bousquet (2008). “The tradeoffs of large scale learning.” NeurIPS.
- L. Bottou, F. Curtis, J. Nocedal (2018). “Optimization methods for large-scale machine learning.” SIAM Review, 60(2).
- A. Nemirovski, A. Juditsky, G. Lan, A. Shapiro (2009). “Robust stochastic approximation approach to stochastic programming.” SIAM Journal on Optimization, 19(4).
- P. Goyal et al. (2017). “Accurate, large minibatch SGD: training ImageNet in 1 hour.” arXiv:1706.02677.
- S. McCandlish, J. Kaplan, D. Amodei (2018). “An empirical model of large-batch training.” arXiv:1812.06162.
- N. Keskar et al. (2017). “On large-batch training for deep learning: generalization gap and sharp minima.” ICLR.
- B. Widrow, M. Hoff (1960). “Adaptive switching circuits.” IRE WESCON Convention Record.
- Y. You et al. (2020). “Large batch optimization for deep learning: training BERT in 76 minutes.” ICLR.
- R. Sutton, A. Barto (2018). Reinforcement Learning: An Introduction, 2nd ed. MIT Press.