Shortcuts

LightningArgumentParser

class lightning.pytorch.cli.LightningArgumentParser(*args, description='pytorch-lightning trainer command line tool', env_prefix='PL', default_env=False, **kwargs)[source]

Bases: ArgumentParser

Extension of jsonargparse’s ArgumentParser for pytorch-lightning.

Initialize argument parser that supports configuration file input.

For full details of accepted arguments see ArgumentParser.__init__.

Parameters
  • description (str) – Description of the tool shown when running --help.

  • env_prefix (str) – Prefix for environment variables. Set default_env=True to enable env parsing.

  • default_env (bool) – Whether to parse environment variables.

add_lightning_class_args(lightning_class, nested_key, subclass_mode=False, required=True)[source]

Adds arguments from a lightning class to a nested key of the parser.

Parameters
Return type

List[str]

Returns

A list with the names of the class arguments added.

add_lr_scheduler_args(lr_scheduler_class=(<class 'torch.optim.lr_scheduler._LRScheduler'>, <class 'lightning.pytorch.cli.ReduceLROnPlateau'>), nested_key='lr_scheduler', link_to='AUTOMATIC')[source]

Adds arguments from a learning rate scheduler class to a nested key of the parser.

Parameters
  • lr_scheduler_class (Union[Type[_LRScheduler], Type[ReduceLROnPlateau], Tuple[Union[Type[_LRScheduler], Type[ReduceLROnPlateau]], ...]]) – Any subclass of torch.optim.lr_scheduler.{_LRScheduler, ReduceLROnPlateau}. Use tuple to allow subclasses.

  • nested_key (str) – Name of the nested namespace to store arguments.

  • link_to (str) – Dot notation of a parser key to set arguments or AUTOMATIC.

Return type

None

add_optimizer_args(optimizer_class=(<class 'torch.optim.optimizer.Optimizer'>, ), nested_key='optimizer', link_to='AUTOMATIC')[source]

Adds arguments from an optimizer class to a nested key of the parser.

Parameters
Return type

None