Lesson 1.10core3 h 30 min⚡ live demo

Optimization: from gradient descent to Adam

How a model actually learns, and why the step size is everything

Everything before this lesson told you which way is downhill; this lesson is about how to walk. Gradient descent, its stochastic mini-batch version, momentum, and adaptive methods like Adam are the algorithms that train every model from linear regression (3.2 Linear regression) to frontier LLMs (8.1 The LLM lifecycle and model landscape). You will see exactly why the learning rate is the most important hyperparameter (4.5 Optimizers and learning-rate schedules, 4.8 Training dynamics and debugging), why narrow valleys make plain gradient descent zigzag, what momentum fixes, and what Adam's update equations actually compute.

You'll be able to

  • Define the optimization problem, convexity, and the difference between local minima, global minima and saddle points
  • Derive the stable step-size range for gradient descent on a quadratic and relate convergence speed to the condition number
  • Explain stochastic gradient descent as an unbiased noisy estimate and reason about batch size
  • Write and interpret the update equations of momentum, RMSProp, Adam and AdamW, including bias correction, and describe standard learning-rate schedules

Key ideas

  1. Convex losses have only global minima and provable convergence; deep nets are non-convex with many saddles, yet first-order methods work.
  2. On a quadratic with curvature a, GD converges iff η < 2/a; in many dimensions η < 2/λmax, while progress along the flattest direction scales with 1/κ — the zigzag of narrow valleys.
  3. SGD's mini-batch gradient is unbiased with variance ∝ 1/|B|; the noise costs accuracy but helps escape saddles and regularizes.
Show 5 more key ideas
  1. Momentum (v ← βv + g) builds speed along consistent directions (up to 1/(1−β)× the step) and cancels oscillations, improving κ to about √κ.
  2. Adam: m and v are EMAs of g and g²; bias-correct by 1 − βᵗ; step η m̂/(√v̂ + ε) is a per-parameter signal-to-noise ratio; defaults 0.9, 0.999, 1e−8.
  3. AdamW decouples weight decay from the adaptive step and is the default for transformers.
  4. Warmup then cosine decay is the standard schedule; the learning rate is the single most important hyperparameter.
  5. Lagrange multipliers (∇f = λ∇g) connect constraints to penalties: regularization is constrained optimization.

Suggested path through this lesson