noether.core.initializers.previous_run

Classes

PreviousRunInitializerConfig

PreviousRunInitializer

Initializes a model from a checkpoint of a previous run (specified by the run_id), this initializers hence only loads model weights.

Module Contents

class noether.core.initializers.previous_run.PreviousRunInitializerConfig(/, **data)

Bases: noether.core.initializers.checkpoint.CheckpointInitializerConfig

Parameters:

data (Any)

kind: Literal['noether.core.initializers.PreviousRunInitializer'] = 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

keys_to_remove: list[str] | None = None

List of keys to remove from the checkpoint.

patterns_to_remove: list[str] | None = None

List of patterns to remove from the checkpoint.

patterns_to_rename: list[dict] | None = None

List of patterns to rename in the checkpoint.

patterns_to_instantiate: list[str] | None = None

List of patterns to instantiate in the checkpoint.

class noether.core.initializers.previous_run.PreviousRunInitializer(initializer_config, **kwargs)

Bases: noether.core.initializers.checkpoint.CheckpointInitializer

Initializes a model from a checkpoint of a previous run (specified by the run_id), this initializers hence only loads model weights. When a previous run should be resumed for further training, use ResumeInitializer instead. This initializer needs to be initialized as part of a model config. It is possible to remove certain keys or patterns from the checkpoint before loading it into the model, or to rename certain patterns.

For example:

model:
  kind: path.to.MyModelClass
  param1: value1
  name: my_model
  initializers:
    - kind: noether.core.initializers.PreviousRunInitializer
    run_id: <run_id>
    model_name: transformer
    stage_name: train
    checkpoint_tag: last
    keys_to_remove:
        - encoder.block1.weight
Parameters:
keys_to_remove
patterns_to_remove
patterns_to_rename
patterns_to_instantiate
init_weights(model, model_name=None)

Initialize the model weights from the checkpoint.

Parameters:
Return type:

None

init_callbacks(callbacks, model)

Initialize the callbacks from the checkpoint.

Parameters:
Return type:

None