Domain

Optimization

How neural networks are trained: gradient steps, learning rates and schedules, curvature and sharpness, and adaptive optimizers such as Adam.

6 notebooks6 demos
Preview the recommended route
First notebookGradient Descent

Start here. Make one prediction, then note what carries over to the next notebook.

θ_t∇L(θ)updateθ_{t+1}
Open first notebook
QuestionWhat carries over from Gradient Descent into Adam Optimizer?
PredictionBefore opening the first demo, predict which quantity changes first.
Demos6 interactive demos in this domain
Before moving onSay in one sentence how the idea works before going to the next notebook.
LearnerWhich notebook should I read first?

Read the first notebook, make one prediction in its demo, then go on to the next.

Open the first notebook

Recommended route

Read these in order: each notebook comes after the notebooks in this domain that it builds on, and the label beside it gives its level. A prerequisite with no page here yet is marked as outside reading. A notebook is left out of the route only when a prerequisite has neither a page here nor a named outside reading; the full list below marks it.

  1. 01
    Gradient Descent

    Gradient descent turns local slope information into an iterative update rule for reducing a loss.

    Introductory20 mincodedemoafter Derivatives
  2. 02
    Adam Optimizer

    Adam combines momentum, a running average of gradients, with a per-parameter step size scaled by a running average of squared gradients.

    Intermediate16 mincodedemoafter Derivatives, Gradient Descent

    Adam Optimizer builds directly on Gradient Descent.

  3. 03
    Loss Landscapes, Sharpness & Flat Minima

    What 2D slices of a loss surface show and hide, how Hessian curvature measures sharpness, why the link between flat minima and generalization is contested, and how SAM trains toward flat regions.

    Intermediate16 mincodedemoafter Adam Optimizer

    Loss Landscapes, Sharpness & Flat Minima builds directly on Adam Optimizer.

  4. 04
    Gradient Clipping & Explosion Prevention

    Norm clipping rescales gradients above a threshold while preserving their direction. It bounds a plain gradient-descent step, but the same bound need not hold for an adaptive optimizer that rescales coordinates or averages earlier gradients.

    Intermediate13 mincodedemoafter Backpropagation, Loss Landscapes, Sharpness & Flat Minima

    Gradient Clipping & Explosion Prevention builds directly on Loss Landscapes, Sharpness & Flat Minima.

  5. 05
    Learning Rate Schedules: Warmup, Decay & Cycling

    How warmup, decay and cyclical schedules change the learning rate over a training run, including the Transformer's warmup with inverse-square-root decay and cosine annealing.

    Intermediate14 mincodedemoafter Adam Optimizer, Loss Landscapes, Sharpness & Flat Minima
  6. 06
    Weight Decay & AdamW: Decoupled Regularization

    Why shrinking weights is not the same as adding an L2 penalty inside Adam, and how AdamW restores the intended regularization behavior.

    Intermediate13 mincodedemoafter Adam Optimizer, Maximum Likelihood

All notebooks

Every published notebook in this domain.