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.nn as nn
>>> model = nn.Linear(4, 2)
>>> 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):
... optimizer.step()
... scheduler.step()