SDE & MLE Prep

Gradient Descent & Optimizers

Q: Explain SGD, momentum, and Adam. How do you choose the learning rate?

  • Batch GD: exact gradient, expensive. SGD / mini-batch: noisy but cheap, the noise helps escape sharp minima; batch size 32–4096.
  • Momentum: v = βv + g; w -= lr·v → accelerates along consistent directions, damps oscillation.
  • RMSProp: divides by a running RMS of gradients → per-parameter step sizes.
  • Adam: momentum (1st moment m) + RMSProp (2nd moment v) with bias correction: m = β1·m + (1−β1)g, v = β2·v + (1−β2)g², w -= lr · m̂ / (√v̂ + ε). AdamW decouples weight decay (the default for transformers).
  • Learning rate: the most important hyperparameter. Use warmup then cosine/linear decay; LR range test; too high → divergence/loss spikes, too low → slow, stuck.
loss surface (narrow valley)
SGD:       /\/\/\/\/\/\--> zig-zags across the valley
Momentum:  ~~~~~~~~~~~~--> builds speed along the valley floor