All problems
Cosine Schedule Value at Step
Problem
Cosine annealing sets lr_t = lr_min + 0.5 * (lr_max - lr_min) * (1 + cos(pi * t / T)).
Given lr_max, lr_min, t, and total steps T > 0, return the learning rate at step t.
Hint
The cosine sweeps from 1 to -1 as t goes from 0 to T.
Test cases
case 1
in: [0.1,0,0,100]
expected: 0.1
case 2
in: [0.1,0.001,50,100]
expected: 0.0505
case 3
in: [0.2,0,100,100]
expected: 0
Starter codePython
def cosine_schedule_value_at_step(lr_max, lr_min, t, total):
# Your code here
pass3 test cases · run your code against them in the editor