Skip to content

Instantly share code, notes, and snippets.

@hadifar
Last active August 19, 2018 13:22
Show Gist options
  • Select an option

  • Save hadifar/323803dfd7a09da6d8d941d480b3be6e to your computer and use it in GitHub Desktop.

Select an option

Save hadifar/323803dfd7a09da6d8d941d480b3be6e to your computer and use it in GitHub Desktop.
import tensorflow as tf
dataset = tf.data.TextLineDataset("file.txt")
iterator = dataset.make_initializable_iterator()
next_element = iterator.get_next()
init_op = iterator.initializer
with tf.Session() as sess:
# Initialize the iterator
sess.run(init_op)
print(sess.run(next_element))
print(sess.run(next_element))
# Move the iterator back to the beginning
print(sess.run(next_element))
sess.run(init_op)
print(sess.run(next_element))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment