Optimizers and Learning Rate Schedules

SGD with momentum, Adam and AdamW, warmup and decay schedules, and how to find a learning rate that works.

Intermediate · about 4 hours · difficulty 3/5

Learn first: Activation and Loss Functions, Optimization and Gradient Descent

The optimizer and learning rate decide whether a network trains fast, slowly or not at all. Most practitioners use a small set of well-understood defaults.

Optimizers

  • SGD with momentum: accumulates a velocity to smooth noisy gradients; still strong for vision with good schedules.
  • RMSProp: per-parameter step sizes from recent gradient magnitudes.
  • Adam: momentum plus adaptive scaling; robust default.
  • AdamW: Adam with decoupled weight decay; the standard for transformers.

Learning rate

  • The single most important hyperparameter. Typical Adam starting points are around 1e-3 for small nets and 1e-4 or lower for fine-tuning large pretrained models.
  • LR range test: increase the rate exponentially over a short run and pick a value just before the loss blows up.
  • Schedules: step decay, cosine annealing, one-cycle, and linear warmup for large models.

Batch size

Larger batches give smoother gradients and better hardware utilization but may need a higher learning rate and can generalize slightly worse. Use gradient accumulation to simulate large batches on small GPUs.

Good enough to move on when you can run an LR range test, pick an optimizer and schedule, and justify the choice from loss curves.

Key concepts

  • SGD with momentum
  • Adam and AdamW
  • Learning rate range test
  • Cosine, step and one-cycle schedules
  • Warmup
  • Batch size and gradient accumulation

Mini project

Train a small CNN on CIFAR-10 with SGD+momentum, Adam and AdamW, each with and without a cosine schedule, and compare validation accuracy after a fixed epoch budget.

Check yourself

What is the practical difference between L2 regularization in Adam and decoupled weight decay in AdamW?

Free resources