tensorflow / 2.9.1 / compat / v1 / data / make_one_shot_iterator.html /

tf.compat.v1.data.make_one_shot_iterator

Creates an iterator for elements of dataset.

Migrate to TF2

This is a legacy API for consuming dataset elements and should only be used during transition from TF 1 to TF 2. Note that using this API should be a transient state of your code base as there are in general no guarantees about the interoperability of TF 1 and TF 2 code.

In TF 2 datasets are Python iterables which means you can consume their elements using for elem in dataset: ... or by explicitly creating iterator via iterator = iter(dataset) and fetching its elements via values = next(iterator).

Description

Note: The returned iterator will be initialized automatically. A "one-shot" iterator does not support re-initialization.
Args
dataset A tf.data.Dataset.
Returns
A tf.data.Iterator for elements of dataset.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/compat/v1/data/make_one_shot_iterator