Decaying squared-gradient cache
Medium TrainingImplement RMSProp from scratch. RMSProp keeps a decaying average of squared gradients so each weight gets its own effective learning rate — large-gradient weights take smaller steps, and the step size stays healthy instead of shrinking to zero like AdaGrad.
Implement the class below. Use only basic PyTorch operations.
Use this code to debug before submitting.
Try solving it yourself first! Click below to reveal the solution.
For interactive practice with auto-grading, run TorchCode locally:pip install torch-judge then use check("rmsprop")
Per-parameter adaptive learning rate via a decaying (leaky) average of squared gradients. The alpha decay (≈0.99) forgets old gradients, so unlike AdaGrad the effective step does not collapse. Covered in DL Module 7 §5.