๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #101

RMSProp

RMSProp keeps AdaGrad's core idea โ€” per-parameter adaptive learning rates based on gradient history โ€” but fixes its fatal flaw with one small change: replacing the ever-growing sum of squared gradients with a decaying average that "forgets" old gradients over time.

Formula

\[ E[g^2]_t = \beta E[g^2]_{t-1} + (1-\beta)g_t^2, \qquad w_{t+1} = w_t - \frac{\eta}{\sqrt{E[g^2]_t}+\epsilon}g_t \]

\(\beta\) (commonly 0.9) controls how much weight recent squared gradients get versus older ones โ€” this is an exponentially weighted moving average, not a running sum. Because it's an average rather than an ever-growing sum, \(E[g^2]_t\) can go back down if recent gradients happen to be small, letting the effective learning rate recover instead of shrinking forever.

Directly Fixing AdaGrad's Problem

AdaGradRMSProp
AccumulatorSum of ALL past squared gradients (\(G_t = G_{t-1}+g_t^2\))Exponentially decaying average (\(E[g^2]_t = \beta E[g^2]_{t-1}+(1-\beta)g_t^2\))
Behavior over long trainingEffective learning rate shrinks monotonically toward zeroEffective learning rate adapts continuously to recent gradient magnitude, never permanently vanishing
Suited to long training runs?PoorlyWell

Numerical Example

With \(\beta=0.9\), \(E[g^2]_0=0\): gradient \(g_1=4\) gives \(E[g^2]_1 = 0.9(0)+0.1(16)=1.6\). If gradients then shrink to \(g=1\) for several steps, \(E[g^2]\) gradually decays back down toward \(0.1(1)=0.1\) โ€” the effective learning rate recovers, something AdaGrad's ever-growing sum could never do.

Code

import torch.optim as optim

optimizer = optim.RMSprop([w], lr=0.001, alpha=0.9)   # alpha is PyTorch's name for beta here

Where It's Used Today

RMSProp was widely used and effective for training recurrent neural networks (see the RNN category) before Adam's popularity grew, and it remains a solid, reasonable choice โ€” Adam, covered next, essentially combines RMSProp's per-parameter adaptive scaling with momentum, making Adam the more common default today.

Common Mistakes

  • Confusing RMSProp's \(\beta\) (controlling the squared-gradient average's decay) with momentum's \(\beta\) (controlling the raw-gradient average's decay) โ€” they serve structurally similar but distinct roles, and Adam (next) uses both simultaneously with separate hyperparameters for each.

Interview Relevance

Q: "How does RMSProp solve AdaGrad's diminishing learning rate problem?" By replacing AdaGrad's ever-growing sum of squared gradients with an exponentially decaying average, which can decrease as well as increase depending on recent gradient magnitudes โ€” this lets the effective per-parameter learning rate adapt continuously throughout training instead of shrinking irreversibly toward zero.

Practice Question

If a parameter's gradients suddenly become much larger after a long period of small gradients, how would RMSProp's effective learning rate for that parameter respond, compared to how AdaGrad's would respond?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

RMSProp โ€“ FAQs

Quick answers about learning RMSProp in Deep Learning.

This free note from CodingNow 2.0 explains RMSProp in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including RMSProp, is 100% free with no signup required.
With focused practice, most students grasp RMSProp in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now