Shortcuts

LightningCLI

class lightning.pytorch.cli.LightningCLI(model_class=None, datamodule_class=None, save_config_callback=<class 'lightning.pytorch.cli.SaveConfigCallback'>, save_config_kwargs=None, trainer_class=<class 'lightning.pytorch.trainer.trainer.Trainer'>, trainer_defaults=None, seed_everything_default=True, parser_kwargs=None, subclass_mode_model=False, subclass_mode_data=False, args=None, run=True, auto_configure_optimizers=True)[소스]

기반 클래스: object

Implementation of a configurable command line tool for pytorch-lightning.

Receives as input pytorch-lightning classes (or callables which return pytorch-lightning classes), which are called / instantiated using a parsed configuration file and / or command line args.

Parsing of configuration from environment variables can be enabled by setting parser_kwargs={"default_env": True}. A full configuration yaml would be parsed from PL_CONFIG if set. Individual settings are so parsed from variables named for example PL_TRAINER__MAX_EPOCHS.

For more info, read the CLI docs.

매개변수
add_arguments_to_parser(parser)[소스]

Implement to add extra arguments to the parser or link arguments.

매개변수

parser (LightningArgumentParser) – The parser object to which arguments can be added

반환 형식

None

add_core_arguments_to_parser(parser)[소스]

Adds arguments from the core classes to the parser.

반환 형식

None

add_default_arguments_to_parser(parser)[소스]

Adds default arguments to the parser.

반환 형식

None

before_instantiate_classes()[소스]

Implement to run some code before instantiating the classes.

반환 형식

None

static configure_optimizers(lightning_module, optimizer, lr_scheduler=None)[소스]

Override to customize the configure_optimizers() method.

매개변수
  • lightning_module (LightningModule) – A reference to the model.

  • optimizer (Optimizer) – The optimizer.

  • lr_scheduler (Union[LRScheduler, ReduceLROnPlateau, None]) – The learning rate scheduler (if used).

반환 형식

Any

init_parser(**kwargs)[소스]

Method that instantiates the argument parser.

반환 형식

LightningArgumentParser

instantiate_classes()[소스]

Instantiates the classes and sets their attributes.

반환 형식

None

instantiate_trainer(**kwargs)[소스]

Instantiates the trainer.

매개변수

kwargs (Any) – Any custom trainer arguments.

반환 형식

Trainer

Creates argument links for optimizers and learning rate schedulers that specified a link_to.

반환 형식

None

parse_arguments(parser, args)[소스]

Parses command line arguments and stores it in self.config.

반환 형식

None

setup_parser(add_subcommands, main_kwargs, subparser_kwargs)[소스]

Initialize and setup the parser, subcommands, and arguments.

반환 형식

None

static subcommands()[소스]

Defines the list of available subcommands and the arguments to skip.

반환 형식

Dict[str, Set[str]]