A SaveableObject for saving/restoring iterator state using Saver.
Raises
ValueError
If iterator does not support checkpointing.
For example:
withtf.Graph().as_default():ds=tf.data.Dataset.range(10)iterator=ds.make_initializable_iterator()# Build the iterator SaveableObject.saveable_obj=tf.data.experimental.make_saveable_from_iterator(iterator)# 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()whilecontinue_training:...Performtraining...ifshould_save_checkpoint:saver.save()
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.data.experimental.make_saveable_from_iterator\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/data/experimental/make_saveable_from_iterator) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/data/experimental/ops/iterator_ops.py#L30-L72) |\n\nReturns a SaveableObject for saving/restoring iterator state using Saver.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.data.experimental.make_saveable_from_iterator`](/api_docs/python/tf/data/experimental/make_saveable_from_iterator)\n\n\u003cbr /\u003e\n\n tf.data.experimental.make_saveable_from_iterator(\n iterator\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|-----------|\n| `iterator` | Iterator. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A SaveableObject for saving/restoring iterator state using Saver. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|---------------------------------------------|\n| `ValueError` | If iterator does not support checkpointing. |\n\n\u003cbr /\u003e\n\n#### For example:\n\n with tf.Graph().as_default():\n ds = tf.data.Dataset.range(10)\n iterator = ds.make_initializable_iterator()\n # Build the iterator SaveableObject.\n saveable_obj = tf.data.experimental.make_saveable_from_iterator(iterator)\n # Add the SaveableObject to the SAVEABLE_OBJECTS collection so\n # it can be automatically saved using Saver.\n tf.compat.v1.add_to_collection(tf.GraphKeys.SAVEABLE_OBJECTS, saveable_obj)\n saver = tf.compat.v1.train.Saver()\n\n while continue_training:\n ... Perform training ...\n if should_save_checkpoint:\n saver.save()\n\n| **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.\n| **Note:** Not all iterators support checkpointing yet. Attempting to save the state of an unsupported iterator will throw an error."]]