TensorPlay
API symbolsoptim
Copy
View MarkdownDownload .md

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 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[float | Tensor]

Note

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

step(epoch: int | None = None) None

Step the scheduler.

Parameters:

epoch (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() without arguments instead.

Note

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

Ask DeepWiki