class

ExponentialLR

extends_LRScheduler
ExponentialLR(optimizer: Optimizer, gamma: float, last_epoch: int = -1, verbose: bool = False)
source

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:

ηt=η0γt\eta_t = \eta_0 \cdot \gamma^{t}

Parameters

optimizerOptimizer
Wrapped optimizer.
gammafloat
Multiplicative factor applied each epoch. Values in (0, 1) produce decay; values greater than 1 produce growth (rarely useful).
last_epochint= -1
The index of the last epoch (default: -1).
verbosebool= False
Print the updated LR after each step if True (default: False).

Attributes

gammafloat
Multiplicative 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)
source

Initialise the ExponentialLR. See the class docstring for parameter semantics.

fn

get_lr

list[float]
get_lr()
source

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.