tf.train.CheckpointManager

View source on GitHub

Deletes old checkpoints.

tf.train.CheckpointManager(
    checkpoint, directory, max_to_keep, keep_checkpoint_every_n_hours=None,
    checkpoint_name='ckpt'
)

Example usage:

import tensorflow as tf
checkpoint = tf.train.Checkpoint(optimizer=optimizer, model=model)
manager = tf.train.CheckpointManager(
    checkpoint, directory="/tmp/model", max_to_keep=5)
status = checkpoint.restore(manager.latest_checkpoint)
while True:
  # train
  manager.save()

CheckpointManager preserves its own state across instantiations (see the __init__ documentation for details). Only one should be active in a particular directory at a time.

Args:

Attributes:

Raises:

Methods

save

View source

save(
    checkpoint_number=None
)

Creates a new checkpoint and manages it.

Args:

Returns:

The path to the new checkpoint. It is also recorded in the checkpoints and latest_checkpoint properties.