Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-017

Warmup LR

Problem

Linear learning-rate warmup: return base_lr * min(1.0, step / warmup_steps), or base_lr when warmup_steps <= 0.

The signature is warmup_lr(step, warmup_steps, base_lr).

Hint

Clamp the step fraction at 1.0 so the rate plateaus after warmup.

Test cases

case 1
in: [0,100,0.001]
expected: 0
case 2
in: [50,100,0.001]
expected: 0.0005
case 3
in: [100,100,0.001]
expected: 0.001
case 4
in: [200,100,0.001]
expected: 0.001
case 5
in: [10,0,0.01]
expected: 0.01
Starter codePython
def warmup_lr(step, warmup_steps, base_lr):
    # Your code here
    pass

5 test cases · run your code against them in the editor