hookeai.model_architectures.procedures.model_state_files.save_model_state

save_model_state(model, state_type='default', epoch=None, is_remove_posterior=True)[source]

Save model state to file.

Model default state file is stored in model_directory under the name < model_name >.pt.

Model initial state file is stored in model_directory under the name < model_name >-init.pt.

Model state file corresponding to given training epoch is stored in model_directory under the name < model_name >.pt or < model_name >-< epoch >.pt if epoch is known.

Model state file corresponding to the best performance is stored in model_directory under the name < model_name >-best.pt or < model_name >-< epoch >-best.pt if epoch is known.

Parameters:
  • model (torch.nn.Module) – Model.

  • state_type ({'default', 'init', 'epoch', 'best'}, default='default') –

    Saved model state file type. Options:

    ’default’ : Model default state

    ’init’ : Model initial state

    ’epoch’ : Model state of given training epoch

    ’best’ : Model state of best performance

  • epoch (int, default=None) – Training epoch corresponding to current model state.

  • is_remove_posterior (bool, default=True) – Remove model state files corresponding to training epochs posterior to the saved state file. Effective only if saved training epoch is known.