nip.model_cache.save_model_state_dicts

nip.model_cache.save_model_state_dicts#

nip.model_cache.save_model_state_dicts(models: dict[str, Module], hyper_params: HyperParameters | dict, subdir: str, overwrite=True)[source]#

Save a model and its parameters.

The model will be saved in a directory named with a hash of the current time.

Various metadata will be saved in a file named metadata.json in the model directory.

Parameters:
  • models (dict[str, torch.nn.Module]) – The models to save. The keys are the names of the models, and the values are the models themselves.

  • hyper_params (HyperParameters | dict) – The parameters which specify the models.

  • subdir (str) – The subdirectory in which to save the models.

  • overwrite (bool) – Whether to overwrite the model if it already exists. If False and the model already exists, it will do nothing.