saealib.CheckpointCallback#
- class saealib.CheckpointCallback(path, interval=1, format='npz', delete_on_success=False, optimizer=None)[source]#
Bases:
objectCallback that saves checkpoints at regular generation intervals.
Two formats are supported:
'npz': portable numpy format (best-effort reproducibility).'pickle': full optimizer + context state (limited complete reproducibility; version-sensitive).'both': saves both formats each checkpoint.
Register this callback with
register(), or pass it implicitly via thecheckpoint_*parameters ofrun()anditerate().- Parameters:
path (str or Path) – Directory where checkpoint files are saved. Created if absent.
interval (int, optional) – Save a checkpoint every interval generations. Default: 1.
format ({'npz', 'pickle', 'both'}, optional) – Checkpoint format. Default:
'npz'.delete_on_success (bool, optional) – If True, all checkpoint files produced by this callback are deleted when the run terminates normally (
RunEndEvent). Useful to avoid accumulating files after a successful run. Default: False.optimizer (Optimizer or None, optional) – Required when format is
'pickle'or'both'.
Methods
Method Details
- CheckpointCallback.__init__(path, interval=1, format='npz', delete_on_success=False, optimizer=None)[source]#
- Parameters:
path (str | Path)
interval (int)
format (str)
delete_on_success (bool)
optimizer (Optimizer | None)
- Return type:
None
- CheckpointCallback.register(cbmanager)[source]#
Register generation-end and run-end handlers on cbmanager.
- Parameters:
cbmanager (CallbackManager)
- Return type:
None