RMSprop optimizerEasynumpyoptimizationoptimizeradaptivermsprop
RMSprop optimizer
Background
RMSprop fixes Adagrad's vanishing learning rate by tracking an exponential moving average of squared gradients instead of their cumulative sum. The accumulator can shrink as well as grow, so the per-parameter step size adapts to recent gradient magnitude — a robust default for RNNs and online settings.
Problem statement
Implement rmsprop_optimizer(parameter, grad, G, learning_rate=0.01, beta=0.9, epsilon=1e-8) for one update step:
Return the updated parameter and accumulator, rounded to 5 decimals.
Input
parameter,grad,G— current value(s), gradient, and EMA accumulator (same shape;Gstarts at 0).learning_rate—float, .beta—float, the EMA decay (default 0.9).epsilon—float.
Output
Returns (updated_parameter, updated_G), each rounded to 5 decimals.
Examples
Example 1
Input: parameter = 1.0, grad = 0.1, G = 1.0, learning_rate = 0.01, beta = 0.9
Output: (0.99895, 0.901)
Explanation: ; the step is , so .
Constraints
- Update as an EMA () before computing the step.
- Step .
- Round both outputs to 5 decimals.
Notes
- Versus Adagrad: replacing the cumulative sum with an EMA lets forget old gradients, so the effective rate doesn't decay to zero on long runs.
- Adam is essentially RMSprop's second-moment EMA plus a first-moment (momentum) EMA with bias correction.
Python
Loading...
This problem ships 4 hidden tests. They run in your browser via Pyodide — no backend, no submission queue. Press ▶ Run tests to execute.
- •Reference example
- •Accumulator is an EMA of squared gradients
- •beta = 0 sets G to grad squared
- •Works elementwise on arrays