Implement the StepLR learning rate scheduler. The learning rate is decayed by a factor gamma every step_size epochs.
def step_lr(initial_lr: float, step_size: int, gamma: float, epoch: int) -> float:
return initial_lr * (gamma ** (epoch // step_size))step_size intervals have passed: epoch // step_size.gamma raised to that power.initial_lr=0.1, step_size=30, gamma=0.1: at epoch 0-29 the LR is 0.1, at epoch 30-59 it is 0.01, and so on.