Gradient Descent
Easy
Learning Rate Decay
Easy
~10 min
code completion
Learning Rate Decay
A fixed learning rate is a compromise: large enough to make fast progress early, small enough to converge precisely later. Exponential decay solves this by shrinking the learning rate over time:
where:
At epoch 0, . Each epoch multiplies by .
Your task:
Implement decay_lr(initial_lr, decay_rate, epoch) that returns the decayed learning rate.
Example Tests
Epoch 0: no decay
Input: {"epoch":0,"decay_rate":0.9,"initial_lr":0.1}
Expected: 0.1
Epoch 1: single decay step
Input: {"epoch":1,"decay_rate":0.9,"initial_lr":0.1}
Expected: 0.09
Halving decay after 4 epochs
Input: {"epoch":4,"decay_rate":0.5,"initial_lr":1}
Expected: 0.0625