class
MultiStepLR
extends
_LRSchedulerMultiStepLR(optimizer: Optimizer, milestones: list[int], gamma: float = 0.1, last_epoch: int = -1, verbose: bool = False)Decay the learning rate by a fixed factor at a list of epoch milestones.
Unlike StepLR, the decay epochs need not be evenly spaced.
At each epoch listed in milestones the learning rate is multiplied
by gamma:
Parameters
optimizerOptimizerWrapped optimizer.
milestoneslist of intSorted list of epoch indices at which the learning rate is decayed.
If unsorted, the list is sorted internally.
gammafloat= 0.1Multiplicative factor applied at each milestone (default:
0.1).last_epochint= -1The index of the last epoch (default:
-1).verbosebool= FalsePrint the updated LR after each step if
True (default: False).Attributes
milestoneslist of intSorted epoch indices where decay is applied.
gammafloatMultiplicative decay factor.
Notes
Useful when natural training phases occur at irregular intervals (e.g., decay at epochs 50, 100, and 150 in a 200-epoch run).
Examples
>>> import lucid.optim as optim
>>> optimizer = optim.SGD(model.parameters(), lr=0.1)
>>> scheduler = optim.MultiStepLR(optimizer, milestones=[50, 100, 150], gamma=0.1)
>>> for epoch in range(200):
... train(...)
... optimizer.step()
... scheduler.step()Methods (2)
dunder
__init__
→None__init__(optimizer: Optimizer, milestones: list[int], gamma: float = 0.1, last_epoch: int = -1, verbose: bool = False)Initialise the MultiStepLR. See the class docstring for parameter semantics.
fn
get_lr
→list[float]get_lr()Compute the learning rate for each parameter group at the current step.
Returns
list[float]One learning rate per param group, derived from the schedule formula documented in the class docstring.