LightningArgumentParser¶
- class lightning.pytorch.cli.LightningArgumentParser(*args, description='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:
- 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 '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 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: