Step, Exponential and One-Cycle LR Schedules

easy
Unit 3 · Optimization0/3 to milestone

Implement three common learning-rate schedules as functions of the step number (0-based):

  • step_decay(step, base_lr, drop=0.1, every=30): multiply by drop after every every steps
  • exponential_decay(step, base_lr, gamma=0.96, decay_steps=100, staircase=False): base_lr * gamma ** (step / decay_steps), using integer division in the exponent if staircase
  • one_cycle(step, total_steps, max_lr, pct_start=0.3, div=25.0, final_div=1e4): Leslie Smith's one-cycle policy. Rise linearly from max_lr / div to max_lr over the first pct_start * total_steps steps, then follow a cosine down to max_lr / (div * final_div) at the last step (total_steps - 1).
#optimization#learning-rate#training2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Step, Exponential and One-Cycle LR Schedules · TechGradify