braintools.trainer.find_checkpoint

braintools.trainer.find_checkpoint#

braintools.trainer.find_checkpoint(dirpath, pattern='*.ckpt', best=False, last=False)[source]#

Find a checkpoint file in a directory.

Parameters:
  • dirpath (str) – Directory to search in.

  • pattern (str) – Glob pattern for checkpoint files.

  • best (bool) – Return the best checkpoint (by name, looking for ‘best’ in filename).

  • last (bool) – Return the last/most recent checkpoint.

Returns:

Path to the found checkpoint, or None if not found.

Return type:

str | None

Examples

>>> checkpoint = find_checkpoint('checkpoints/', best=True)
>>> checkpoint = find_checkpoint('checkpoints/', last=True)