CheckpointSaver

class tfsnippet.CheckpointSaver(variables, save_dir, objects=None, filename='checkpoint.dat', max_to_keep=None, save_meta=True, name=None, scope=None)

Bases: tfsnippet.utils.reuse.VarScopeObject

Save and restore tf.Variable, ScheduledVariable and CheckpointSavableObject with tf.train.Saver.

Attributes Summary

filename Get the filename of checkpoint files.
name Get the name of this object.
save_dir Get the checkpoint directory.
save_meta Whether or not to save graph meta?
saver Get the TensorFlow saver object.
variable_scope Get the variable scope of this object.

Methods Summary

latest_checkpoint() Get the path of the latest checkpoint file.
recover_internal_states() Restore the internal states of this saver.
restore(save_path[, session]) Restore from a checkpoint file.
restore_latest([ignore_non_exist, session]) Restore the latest checkpoint file.
save([global_step, session]) Save the session to a checkpoint file.

Attributes Documentation

filename

Get the filename of checkpoint files.

name

Get the name of this object.

save_dir

Get the checkpoint directory.

save_meta

Whether or not to save graph meta?

saver

Get the TensorFlow saver object.

Returns:The TensorFlow saver object.
Return type:tf.train.Saver
variable_scope

Get the variable scope of this object.

Methods Documentation

latest_checkpoint()

Get the path of the latest checkpoint file.

Returns:
The path of the latest checkpoint file, or
None if no checkpoint file is found.
Return type:str or None
recover_internal_states()

Restore the internal states of this saver.

restore(save_path, session=None)

Restore from a checkpoint file.

Parameters:
  • save_path (str) – Restore from this checkpoint file.
  • session (tf.Session) – Restore the variables into this session. If not specified, restore into the default session.
restore_latest(ignore_non_exist=False, session=None)

Restore the latest checkpoint file. :param ignore_non_exist: Whether or not to ignore error if the

latest checkpoint file does not exist?
Parameters:session (tf.Session) – Restore the variables into this session. If not specified, restore into the default session.
Raises:IOError – If no checkpoint file is found.
save(global_step=None, session=None)

Save the session to a checkpoint file.

Parameters:
  • global_step (int or tf.Tensor) – The global step counter.
  • session (tf.Session) – The session to save. If not specified, select the default session.
Returns:

The path of the saved checkpoint file.

Return type:

str