Skip to content
DeepForgeby svx
All problems
MediumOptimizationop-344

Warmup Linear Scale Factor

Problem

Linear warmup scales the peak learning rate by t / T_warm, capped at one once the warmup horizon is passed.

Given t and T_warm > 0, return the scale factor min(1, t / T_warm).

Hint

The factor saturates at one.

Test cases

case 1
in: [5,10]
expected: 0.5
case 2
in: [10,10]
expected: 1
case 3
in: [20,10]
expected: 1
Starter codePython
def warmup_linear_scale_factor(t, warmup):
    # Your code here
    pass

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