All problems
Step-Decay Learning Rate
Problem
Compute the learning rate at a given step with step decay:
lr(step) = base_lr * drop^(step // every)
If every is not positive, return base_lr unchanged.
Hint
Integer division gives the number of completed decay periods.
Test cases
case 1
in: [0.1,0.5,10,0]
expected: 0.1
case 2
in: [0.1,0.5,10,9]
expected: 0.1
case 3
in: [0.1,0.5,10,10]
expected: 0.05
case 4
in: [0.1,0.5,10,25]
expected: 0.025
case 5
in: [0.1,0.5,0,7]
expected: 0.1
Starter codePython
def step_decay_lr(base_lr, drop, every, step):
# Your code here
pass5 test cases · run your code against them in the editor