torchkit.experiment

Methods useful for running experiments.

torchkit.experiment.setup_experiment(exp_dir, config, resume=False)[source]

Initializes an experiment.

If the experiment directory doesn’t exist yet, creates it and dumps the config dict as a yaml file and git hash as a text file. If it exists already, raises a ValueError to prevent overwriting unless resume is set to True. If it exists already and resume is set to True, inplace updates the config with the values in the saved yaml file.

Parameters
  • exp_dir (str) – Path to the experiment directory.

  • config (ConfigDict) – The config for the experiment.

  • resume (bool, optional) – Whether to resume from a previously created experiment. Defaults to False.

Raises

ValueError – If the experiment directory exists already and resume is not set to True.

Return type

None

torchkit.experiment.string_from_kwargs(**kwargs)[source]

Concatenate kwargs into an underscore-separated string.

Used to generate an experiment name based on supplied config kwargs.

Return type

str

Parameters

kwargs (Any) –

torchkit.experiment.unique_id()[source]

Generate a unique ID as specified in RFC 4122.

Return type

str