Switch Scheduler#
- class SwitchScheduler(new_schedulers, epoch_switch)[source]#
Bases:
CallbackCallback to switch scheduler during training.
This callback allows switching between different schedulers during training, enabling the exploration of multiple optimization strategies without interrupting the training process.
- Parameters:
new_schedulers (pina.optim.TorchScheduler | list[pina.optim.TorchScheduler]) – The scheduler or list of schedulers to switch to. Use a single scheduler for single-model solvers, or a list of schedulers when working with multiple models.
epoch_switch (int) – The epoch at which the scheduler switch occurs.
- Raises:
AssertionError – If epoch_switch is less than 1.
ValueError – If each scheduler in
new_schedulersis not an instance ofpina.optim.TorchScheduler.
Example
>>> scheduler = TorchScheduler( >>> torch.optim.lr_scheduler.StepLR, step_size=5 >>> ) >>> switch_callback = SwitchScheduler( >>> new_schedulers=scheduler, epoch_switch=10 >>> )