braintools.trainer.save_checkpoint#
- braintools.trainer.save_checkpoint(state, filepath, overwrite=True)[source]#
Save a checkpoint to disk.
- Parameters:
- Returns:
Path where the checkpoint was saved.
- Return type:
Examples
>>> import os, shutil, tempfile >>> import jax.numpy as jnp >>> import braintools >>> tmp = tempfile.mkdtemp() >>> state = {'weights': jnp.ones((2, 3)), 'epoch': 10} >>> path = braintools.trainer.save_checkpoint( ... state, os.path.join(tmp, 'run', 'checkpoint.ckpt')) >>> os.path.relpath(path, tmp) 'run/checkpoint.ckpt' >>> os.path.exists(path) True >>> shutil.rmtree(tmp)