Skip to content
ML to LLMs
Cheat sheets

Optimizers

Gradient descent variants, momentum, Adam and AdamW, learning-rate schedules, and the stability limit.

OptimizerUpdateNotes
Gradient descentθ←θ−ηg\theta \leftarrow \theta - \eta gfull-batch gradient
SGD / mini-batchsame, gg from a batchstandard; noise helps generalization
Momentumv←βv+gv \leftarrow \beta v + g; θ←θ−ηv\theta \leftarrow \theta - \eta vaccelerates consistent directions, damps zig-zags
Nesterovmomentum with look-ahead gradientslightly faster convergence
RMSPropdivide by running RMS of gradientsper-parameter step sizes
Adambias-corrected moments m^/s^\hat m/\sqrt{\hat s}default for deep nets; little tuning
AdamWAdam + decoupled weight decaydefault for transformers

Stability limit: along a direction with curvature λ\lambda, plain gradient descent needs η<2/λ\eta < 2/\lambda. The steepest direction sets the limit for all.

Schedules: warmup (linear ramp from ~0), then cosine or step decay. Reduce on plateau for classical setups.

Defaults that usually work: AdamW, lr 1e-3 (small models) to 1e-4 or lower (fine-tuning large models), weight decay 0.01, warmup 1 to 5% of steps, gradient clipping at 1.0.

Diagnose with the loss curve: flat (lr too low or broken graph), exploding (lr too high), noisy (batch small or lr high), validation rising (overfitting, not an optimizer problem).

Lessons: Gradient descent · Training and regularization · Lab: gradient descent