noether.core.initializers.checkpoint

Classes

CheckpointInitializerConfig

CheckpointInitializer

Base class to initialize models from checkpoints of previous runs. Should not be used directly, but inherited by other initializers such as PreviousRunInitializer or ResumeInitializer.

Module Contents

class noether.core.initializers.checkpoint.CheckpointInitializerConfig(/, **data)

Bases: noether.core.initializers.base.InitializerConfig

Parameters:

data (Any)

kind: Literal['noether.core.initializers.CheckpointInitializer'] = None
load_optim: bool = None

Whether or not to load the optimizer state from the checkpoint. Default is True, as this is usually used to resume a training run

pop_ckpt_kwargs_keys: list[str] | None = None

which checkpoint to load. If a string is provided, must be one of (“latest”, “best_loss”). If a dictionary is provided, must contain keys “epoch”, “update”, “sample” to identify the checkpoint.

output_path: pathlib.Path | None = None

Output root where the source run (identified by run_id/stage_name) lives. When None, the current run’s path provider is used to locate it, which assumes the source shares this run’s output_path. Set explicitly by noether-eval so that overriding output_path for the eval run doesn’t redirect source-checkpoint lookup.

class noether.core.initializers.checkpoint.CheckpointInitializer(initializer_config, **kwargs)

Bases: noether.core.initializers.base.InitializerBase

Base class to initialize models from checkpoints of previous runs. Should not be used directly, but inherited by other initializers such as PreviousRunInitializer or ResumeInitializer.

Parameters:
checkpoint_tag: str | noether.core.utils.training.training_iteration.TrainingIteration
run_id
model_name
load_optim
model_info
pop_ckpt_kwargs_keys
stage_name
init_optimizer(model)

Initialize the optimizer for the model if it is derived from Model.

If model is a CompositeModel, nothing happens. This is expected as CompositeModels can be arbitrarily nested and do not have an optimizer. Instead, a CompositeModel calls init_optim with all its submodels which can be of type Model or a nested CompositeModel.

Parameters:

model (noether.core.models.ModelBase) – a model to initialize the optimizer for. Assumes the model has an attribute optim.

Return type:

None