aiaccel.torch.lightning.OptimizerConfig

class aiaccel.torch.lightning.OptimizerConfig(optimizer_generator: ~collections.abc.Callable[[...], ~torch.optim.optimizer.Optimizer], params_transformer: ~collections.abc.Callable[[...], ~collections.abc.Iterator[tuple[str, ~typing.Any]]] | None = None, scheduler_generator: ~collections.abc.Callable[[...], ~torch.optim.lr_scheduler.LRScheduler] | None = None, scheduler_interval: str | None = 'step', scheduler_monitor: str | None = 'validation/loss', schedulers: list[~aiaccel.torch.lightning.opt_lightning_module.LRSchedulerConfig] = <factory>)[source]

Configuration for the optimizer and scheduler in a LightningModule.

Parameters:
  • optimizer_generator (Callable[..., optim.Optimizer]) – A callable that generates the optimizer.

  • params_transformer (Callable[..., Iterator[tuple[str, Any]]] | None) – A callable that transforms the parameters into a format suitable for the optimizer. If None, the parameters are used as is. Defaults to None.

  • scheduler_generator (Callable[..., optim.lr_scheduler.LRScheduler] | None) – (Deprecated) A callable that generates a single learning rate scheduler. If None, no scheduler is used. schedulers is preferred when you need multiple schedulers. Defaults to None.

  • scheduler_interval (str | None) – (Deprecated) The interval at which the single scheduler is called. Defaults to "step".

  • scheduler_monitor (str | None) – (Deprecated) The metric to monitor for the single scheduler. Defaults to "validation/loss".

  • schedulers (list[LRSchedulerConfig]) – A list of scheduler configurations, allowing multiple schedulers with different intervals or monitors. Defaults to an empty list.

__init__(optimizer_generator: ~collections.abc.Callable[[...], ~torch.optim.optimizer.Optimizer], params_transformer: ~collections.abc.Callable[[...], ~collections.abc.Iterator[tuple[str, ~typing.Any]]] | None = None, scheduler_generator: ~collections.abc.Callable[[...], ~torch.optim.lr_scheduler.LRScheduler] | None = None, scheduler_interval: str | None = 'step', scheduler_monitor: str | None = 'validation/loss', schedulers: list[~aiaccel.torch.lightning.opt_lightning_module.LRSchedulerConfig] = <factory>) None

Methods

__init__(optimizer_generator[, ...])

Attributes

params_transformer

scheduler_generator

scheduler_interval

scheduler_monitor

optimizer_generator

schedulers