You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The returned "iterator" is not an iterator, because it does not provide a __next__ or next method. It does provide a get_next method, but that is not what Python expects.
The text was updated successfully, but these errors were encountered:
Is there a technical reason that prevents Iterator from being an iterator? It looks like the iterator does something unexpected, and there is already a warning for that. But as far as I can see, nothing prevents a next() and __next__() method that simply call get_next().
Is there a technical reason that prevents Iterator from being an iterator?
Yes. In TensorFlow (except Eager mode), we use the tf.data.Iterator to get symbolic tf.Tensor objects that can be chained together with other operations to build a dataflow graph. We typically build the graph once, and use it many times. Wrapping the graph construction in a for loop (by using the tf.data.Iterator as a Python iterator) would not be efficient. Furthermore, tf.data.Iterator is implemented using TensorFlow operations, so you would need to provide a tf.Session to run these operations, and the Python iterator protocol doesn't provide a way to do that.
In eager mode, you can wrap a tf.data.Dataset in a tf.contrib.eager.Iterator, which is usable as a Python iterator. This definitely seems to be a more natural use of the tf.data API, and we'd encourage you to try it out!
System information
v1.4.0-19-ga52c8d9 1.4.1
xxx
)Run convert_to_records.py from the official MNIST example, then:
Describe the problem
The returned "iterator" is not an iterator, because it does not provide a
__next__
ornext
method. It does provide aget_next
method, but that is not what Python expects.The text was updated successfully, but these errors were encountered: