cosine
allennlp.training.learning_rate_schedulers.cosine
CosineWithRestarts#
@LearningRateScheduler.register("cosine")
class CosineWithRestarts(LearningRateScheduler):
| def __init__(
| self,
| optimizer: torch.optim.Optimizer,
| t_initial: int,
| t_mul: float = 1.0,
| eta_min: float = 0.0,
| eta_mul: float = 1.0,
| last_epoch: int = -1
| ) -> None
Cosine annealing with restarts.
This is described in the paper https://arxiv.org/abs/1608.03983. Note that early stopping should typically be avoided when using this schedule.
Registered as a LearningRateScheduler
with name "cosine".
Parameters
- optimizer :
torch.optim.Optimizer
This argument does not get an entry in a configuration file for the object. - t_initial :
int
The number of iterations (epochs) within the first cycle. - t_mul :
float
, optional (default =1
)
Determines the number of iterations (epochs) in the i-th decay cycle, which is the length of the last cycle multiplied byt_mul
. - eta_min :
float
, optional (default =0
)
The minimum learning rate. - eta_mul :
float
, optional (default =1
)
Determines the initial learning rate for the i-th decay cycle, which is the last initial learning rate multiplied bym_mul
. - last_epoch :
int
, optional (default =-1
)
The index of the last epoch. This is used when restarting.
get_values#
class CosineWithRestarts(LearningRateScheduler):
| ...
| @overrides
| def get_values(self)
Get updated learning rate.