braintools.trainer.save_checkpoint

braintools.trainer.save_checkpoint#

braintools.trainer.save_checkpoint(state, filepath, overwrite=True)[source]#

Save a checkpoint to disk.

Parameters:
  • state (Dict[str, Any]) – State dictionary to save.

  • filepath (str) – Path to save the checkpoint.

  • overwrite (bool) – Whether to overwrite existing checkpoint.

Returns:

Path where the checkpoint was saved.

Return type:

str

Examples

>>> state = {'model': model.state_dict(), 'epoch': 10}
>>> save_checkpoint(state, 'checkpoint.ckpt')