Skip to content

utils

load_experiment

load_experiment(exp_path, search_path=None)

Loads all configuration and metrics outputs in an experiment directory.

Parameters:

Name Type Description Default
exp_path str | Path

The directory to search for data. Directory must include the ".hydra/config.yaml" file.

required

Returns:

Name Type Description
exps Union[Experiment, List[Experiment]]

load_from_checkpoint

load_from_checkpoint(
    model,
    *,
    ckpt=None,
    weights_key=None,
    weights_key_strip=None,
    model_attr=None,
)

Load model weights.

Parameters:

Name Type Description Default
model Module

The PyTorch Module

required
ckpt Optional[Union[str, Path]]

The path to the file containing the model weights. If no path is provided the model will not be updated.

None
weights_key Optional[str] (default: None)

The key from the checkpoint file containing the model weights. When None, the checkpoint dict is loaded into model directly.

None
weights_key_strip Optional[str] (default: None)

A prefix to remove from each weight's key prior to loading. When None, keys are used as-is.

None
model_attr Optional[str] (default: None)

The attribute of model to load the weights into. When None, they are loaded into model itself.

None

Returns:

Name Type Description
model Module

The same model instance, with its weights loaded.

original_cwd

original_cwd()

Directory the experiment was launched from.

Inside a Hydra job the process cwd is the per-job output directory, so relative paths in a task() silently resolve against the wrong place. Use this to anchor paths against the launch directory instead::

data = load(mushin.original_cwd() / "data" / "train.csv")

Outside a Hydra run this is just the current working directory.