LightningArgumentParser¶
- class pytorch_lightning.cli.LightningArgumentParser(*args, description='pytorch-lightning trainer command line tool', env_prefix='PL', default_env=False, **kwargs)[source]¶
Bases:
object
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:
- 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:
lightning_class¶ (
Union
[Callable
[...
,Union
[Trainer
,LightningModule
,LightningDataModule
,Callback
]],Type
[Trainer
],Type
[LightningModule
],Type
[LightningDataModule
],Type
[Callback
]]) – A callable or any subclass of {Trainer, LightningModule, LightningDataModule, Callback}.nested_key¶ (
str
) – Name of the nested namespace to store arguments.subclass_mode¶ (
bool
) – Whether allow any subclass of the given class.
- Return type:
- 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 'pytorch_lightning.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 oftorch.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: