All problems
Momentum Warmup Factor
Problem
Linearly warm up the momentum coefficient.
Return initial_momentum + (target_momentum - initial_momentum) * min(1, max(0, step / warmup_steps)). If warmup_steps is not positive, return target_momentum immediately.
Hint
Momentum ramps from initial_momentum to target_momentum over the warmup window.
Test cases
case 1
in: [0,10,0.9,0.1]
expected: 0.1
case 2
in: [5,10,0.9,0.1]
expected: 0.5
case 3
in: [10,10,0.9,0.1]
expected: 0.9
case 4
in: [20,10,0.9,0.1]
expected: 0.9
case 5
in: [3,0,0.9,0.1]
expected: 0.9
Starter codePython
def momentum_warmup(step, warmup_steps, target_momentum, initial_momentum):
# Your code here
pass5 test cases · run your code against them in the editor