RMSProp: A Learning Rate per Parameter

OptimizationEasy+10 XP+10

RMSProp: A Learning Rate per Parameter

Plain gradient descent uses one learning rate for every parameter, which goes badly when gradients differ wildly in scale. RMSProp gives each parameter its own effective rate by tracking a decaying average of that parameter's recent squared gradients.

One step, applied element-wise:

1cache = decay_rate * cache + (1 - decay_rate) * grad²
2param = param - learning_rate * grad / (sqrt(cache) + epsilon)

Task: write rmsprop_step(params, grads, cache, learning_rate, decay_rate, epsilon) returning [new_params, new_cache], all values rounded to 4 decimal places.

  • Update the cache first, then use the new cache in the parameter update.
  • epsilon only exists to stop division by zero — don't drop it.

Look at what the division does to units. A consistently large gradient inflates its own denominator, so the actual step size stays roughly constant no matter how steep that direction is. RMSProp is closer to normalising direction than to scaling magnitude.

w1
4.20
w2
0.12
w3
2.80
w4
0.05
w5
1.10

RMSProp divides each gradient by how large that weight's gradients have recently been — so every weight gets a sensible step.

Examples

params = [1.0, 2.0]
grads = [0.5, -0.5]
cache = [0.0, 0.0]
learning_rate = 0.01
decay_rate = 0.9
epsilon = 1e-08
returns [[0.9684, 2.0316], [0.025, 0.025]]
params = [0.0]
grads = [1.0]
cache = [1.0]
learning_rate = 0.1
decay_rate = 0.9
epsilon = 1e-08
returns [[-0.1], [1.0]]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run