Skip to contents

Initializes and runs torch::lr_scheduler()s.

Usage

luz_callback_lr_scheduler(
  lr_scheduler,
  ...,
  call_on = "on_epoch_end",
  opt_name = NULL
)

Arguments

lr_scheduler

A torch::lr_scheduler() that will be initialized with the optimizer and the ... parameters.

...

Additional arguments passed to lr_scheduler together with the optimizers.

call_on

The callback breakpoint that scheduler$step() is called. Default is 'on_epoch_end'. See luz_callback() for more information.

opt_name

name of the optimizer that will be affected by this callback. Should match the name given in set_optimizers. If your module has a single optimizer, opt_name is not used.

Value

A luz_callback() generator.

Examples

if (torch::torch_is_installed()) {
cb <- luz_callback_lr_scheduler(torch::lr_step, step_size = 30)
}