View source

Returns a SaveableObject for saving/restoring iterator state using Saver.




  • iterator: Iterator.


A SaveableObject for saving/restoring iterator state using Saver.


  • ValueError: If iterator does not support checkpointing.

For example:

with tf.Graph().as_default():
  ds =
  iterator = ds.make_initializable_iterator()
  # Build the iterator SaveableObject.
  saveable_obj =
  # Add the SaveableObject to the SAVEABLE_OBJECTS collection so
  # it can be automatically saved using Saver.
  tf.compat.v1.add_to_collection(tf.GraphKeys.SAVEABLE_OBJECTS, saveable_obj)
  saver = tf.compat.v1.train.Saver()

  while continue_training:
    ... Perform training ...
    if should_save_checkpoint:

Note: When restoring the iterator, the existing iterator state is completely discarded. This means that any changes you may have made to the Dataset graph will be discarded as well! This includes the new Dataset graph that you may have built during validation. So, while running validation, make sure to run the initializer for the validation input pipeline after restoring the checkpoint.

免费成长做爱直播有哪些Note: Not all iterators support checkpointing yet. Attempting to save the state of an unsupported iterator will throw an error.

results matching ""

    No results matching ""