Optimizers practice problems
17 problems · 0 solved
An optimizer decides how to change the weights once the gradients are known. Plain gradient descent takes a step straight downhill, while modern optimizers keep running averages to smooth noise and adapt the step size per parameter. Momentum is like a ball rolling down a hill that keeps some speed from earlier steps. These problems ask you to implement the optimizers and schedules used in practice. You will add momentum to gradient descent, take a Nesterov step, take a centered RMSProp step, implement one step of Adam, minimise a quadratic with AdamW, bias correction and a no-decay mask, run the sign-based Lion optimizer, wrap an optimizer with Lookahead, compute Adafactor's factored second moment, clip gradients by global norm, compute the Noam warmup schedule, and combine AdamW with linear warmup and cosine decay. Start with the Easy problems on momentum, clipping and warmup. Then do Adam, RMSProp and Lion, and finish with AdamW schedules and Adafactor. Interviewers often ask how AdamW differs from Adam or why warmup helps, and these details decide whether a large training run converges or diverges.
Easy 7
- Add momentum to gradient descent
- Clip a list of gradients by their combined global norm
- Take a Nesterov momentum step
- Compute the Noam warmup learning rate
- Compute an exponentially weighted average with bias correction
- Run Adagrad on a quadratic with uneven curvature
- Simulate reduce-learning-rate-on-plateau
Medium 7
- Implement one step of the Adam optimizer
- Run the sign-based Lion optimizer with decoupled weight decay
- Take a centered RMSProp step
- Wrap an optimizer with Lookahead
- Run Adadelta, the optimizer with no learning rate
- Build a warmup plus cosine schedule with warm restarts
- Clip gradients unit-wise relative to weight norms (AGC)