towhee.trainer.optimization.optimization.get_scheduler

towhee.trainer.optimization.optimization.get_scheduler(name: Union[str, SchedulerType], optimizer: Optimizer, num_warmup_steps: Optional[int] = None, num_training_steps: Optional[int] = None)[source]

Unified API to get any scheduler from its name.

Parameters:
  • name (str or :obj:`SchedulerType) – The name of the scheduler to use.

  • optimizer (torch.optim.Optimizer) – The optimizer that will be used during training.

  • num_warmup_steps (int, optional) – The number of warmup steps to do. This is not required by all schedulers (hence the argument being optional), the function will raise an error if it’s unset and the scheduler type requires it.

  • num_training_steps (int, optional) – The number of training steps to do. This is not required by all schedulers (hence the argument being optional), the function will raise an error if it’s unset and the scheduler type requires it.