API symbolsoptim
Copy
SWALR
- class tensorplay.optim.swa_utils.SWALR(optimizer: Optimizer, swa_lr: float, anneal_epochs=10, anneal_strategy: Literal['cos', 'linear'] = 'cos', last_epoch=-1)[source]
Anneal each optimizer learning rate to a fixed SWA learning rate.
- get_last_lr() list[float | TensorBase]
Get the most recent learning rates computed by this scheduler.
- Returns:
A
listof learning rates with entries for each of the optimizer’sparam_groups, with the same types as theirgroup["lr"]s.- Return type:
Note
The returned
Tensors are copies, and never alias the optimizer’sgroup["lr"]s.
- step(epoch: int | None = None) None
Step the scheduler.
- Parameters:
epoch (int, optional) –
Deprecated since version 1.4: If provided, sets
last_epochtoepochand uses_get_closed_form_lr()if it is available. This is not universally supported. Usestep()without arguments instead.
Note
Call this method after calling the optimizer’s
step().
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?
