extensible.extensions.soleil#
Functions
|
Instantiates the object (presumbaly a train manager) specified in the solconf description within a checkpoint file and modifies its checkpoint loader to load weights and fixtures from the specified checkpoint_file. |
Classes
|
Checkpoint saver for soleil-configured train managers. |
- class extensible.extensions.soleil.SoleilCheckpointSaver(*args, root_config: Path | str | None = None, package_overrides: List[str] | None = None, **kwargs)#
Bases:
CheckpointSaverCheckpoint saver for soleil-configured train managers. This class is assumed to be instantiated inside a *.solconf file in order to infer values for root_config and package_overrides. Otherwise, you need to supply values for these parameters.
Train managers can be loaded from saved checkpoints using
init_from_checkpoint().Warning
In order for
init_from_checkpoint()to work, it is assumed that the solconf package where this class is instantiated resolves to aTrainManagerinstance – i.e., itsas_typemember instantiates aTrainManagerobject.- Parameters:
path – The path where all values will be saved.
saved_fixtures – The fixtures to save. By default, only
'epoch_num'is saved.saved_attribs – If not specified, all train manager attributes with a
state_dictattribute will be saved. This usually includes the model, optimizer and learning rate scheduler.
a checkpoint to load. When training, set to
Trueto continue training if any checkpoints exist (training will fail with the default valueFalseif checkpoints exist).- post_train_step_epoch(train_manager, fixtures, epoch_num)#
Save a checkpoint
- extensible.extensions.soleil.init_from_checkpoint(checkpoint_file, overrides=None, solconf_package_dir=None)#
Instantiates the object (presumbaly a train manager) specified in the solconf description within a checkpoint file and modifies its checkpoint loader to load weights and fixtures from the specified checkpoint_file.
Note
Since any fixtures need to be loaded in the correct context (e.g., the train or eval stage), the weights and fixtures are not immediately loaded from the checkpoint. Rather the loaded object’s
CheckpointLoaderis modified by setting its ckpt_spec attribute to checkpoint_file. This will allow any fixtures (along with the weights) to load at the correct stage.If needed, weights can be loaded explicitly on the returned train manager using
CheckpointLoader.load_weights_and_fixtures, settingfixtures=Noneto skip loading fixtures.- Parameters:
overrides – Any overrides to apply when building the train manager from its solconf description.
solconf_package_dir – A directory where the checkpoint’s solconf package can be stored. By default, a temporary directory that is discarded before the function exists.