class
ExponentialLR
extends
_LRSchedulerExponentialLR(optimizer: Optimizer, gamma: float, last_epoch: int = -1, verbose: bool = False)Decay the learning rate by a constant factor every epoch.
The learning rate is multiplied by gamma at every epoch, producing
an exponential decay over time:
Parameters
optimizerOptimizerWrapped optimizer.
gammafloatMultiplicative factor applied each epoch. Values in
(0, 1)
produce decay; values greater than 1 produce growth (rarely
useful).last_epochint= -1The index of the last epoch (default:
-1).verbosebool= FalsePrint the updated LR after each step if
True (default: False).Attributes
gammafloatMultiplicative factor applied each epoch.
Notes
ExponentialLR applies the decay at every epoch without any
plateau detection. For a coarser schedule that decays only at
certain milestones, prefer StepLR or MultiStepLR.
Examples
>>> import lucid.optim as optim
>>> optimizer = optim.SGD(model.parameters(), lr=0.1)
>>> scheduler = optim.ExponentialLR(optimizer, gamma=0.95)
>>> for epoch in range(100):
... train(...)
... optimizer.step()
... scheduler.step()Methods (2)
dunder
__init__
→None__init__(optimizer: Optimizer, gamma: float, last_epoch: int = -1, verbose: bool = False)Initialise the ExponentialLR. 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.