Compute a learning rate with linear warm-up followed by cosine decay. For steps t < warmup the rate is lr0 * (t + 1) / warmup. From t = warmup on, with q=min(t−warmup,max(1,T−warmup)), the rate is ηmin+21(η0−ηmin)(1+cos(πq/max(1,T−warmup))).
Implement solve(lr0, min_lr, t, warmup, T).
Returns. Return the learning rate as a float. It reaches lr0 at t = warmup - 1 and again at t = warmup, then decays to min_lr at t = T.
Example 1
Input:
solve(1.0, 0.1, 0, 2, 6)
Output:
0.5
Example 2
Input:
solve(1.0, 0.1, 2, 2, 6)
Output:
1.0
Example 3
Input:
solve(1.0, 0.1, 6, 2, 6)
Output:
0.1
No results yet
Run your code to check it against the examples, or submit to run every test.