# SWALR

Source: https://www.tensorplay.cn/docs/generated/tensorplay.optim.swa_utils.SWALR.html

# SWALR

class tensorplay.optim.swa_utils.SWALR(optimizer: [Optimizer](tensorplay.optim.optimizer.Optimizer.html#tensorplay.optim.optimizer.Optimizer), swa_lr: [float](https://docs.python.org/3/library/functions.html#float), anneal_epochs=10, anneal_strategy: Literal['cos', 'linear'] = 'cos', last_epoch=-1)[[source]](../_modules/tensorplay/optim/swa_utils.html#SWALR)

Anneal each optimizer learning rate to a fixed SWA learning rate.

get_last_lr() &#x2192; [list](https://docs.python.org/3/library/stdtypes.html#list)[[float](https://docs.python.org/3/library/functions.html#float) | TensorBase]

Get the most recent learning rates computed by this scheduler.

Returns:

A [list](https://docs.python.org/3/library/stdtypes.html#list) of learning rates with entries
for each of the optimizer’s
param_groups, with the same types as
their group["lr"]s.

Return type:

[list](https://docs.python.org/3/library/stdtypes.html#list)[[float](https://docs.python.org/3/library/functions.html#float) | Tensor]

Note

The returned Tensors are copies, and never alias
the optimizer’s group["lr"]s.

step(epoch: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None) &#x2192; [None](https://docs.python.org/3/library/constants.html#None)

Step the scheduler.

Parameters:

epoch ([int](https://docs.python.org/3/library/functions.html#int), optional) – 
Deprecated since version 1.4: If provided, sets last_epoch to epoch and uses
_get_closed_form_lr() if it is available. This is not
universally supported. Use [step()](#tensorplay.optim.swa_utils.SWALR.step) without arguments
instead.

Note

Call this method after calling the optimizer’s
step().
