class
PolynomialLR
extends
_LRSchedulerPolynomialLR(optimizer: Optimizer, total_iters: int = 5, power: float = 1.0, last_epoch: int = -1, verbose: bool = False, eta_min: float = 0.0)Decay the learning rate using a polynomial function over a fixed number of steps.
The learning rate follows a polynomial decay from the base LR down to
eta_min over total_iters epochs:
where and .
Parameters
optimizerOptimizerWrapped optimizer.
total_itersint= 5Number of epochs over which the decay runs (default:
5).powerfloat= 1.0Exponent of the polynomial.
power=1 gives linear decay;
power=2 gives quadratic decay (default: 1.0).last_epochint= -1The index of the last epoch (default:
-1).verbosebool= FalsePrint the updated LR after each step if
True (default: False).eta_minfloat= 0.0Minimum learning rate reached at
total_iters (default: 0.0).Attributes
total_itersintDecay period in epochs.
powerfloatPolynomial exponent.
eta_minfloatLower bound on the learning rate.
Notes
power=1 (linear) is equivalent to LinearLR with
start_factor=1 and end_factor=0. Higher powers produce a
schedule that decays slowly at first and more steeply near the end.
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.PolynomialLR(
... optimizer, total_iters=100, power=2.0, eta_min=1e-5
... )
>>> for epoch in range(100):
... optimizer.step()
... scheduler.step()