ray.data.Dataset.iterator#

Dataset.iterator() ray.data.dataset_iterator.DatasetIterator[source]#

Return a DatasetIterator that can be used to repeatedly iterate over the dataset.

Note

Calling any of the consumption methods on the returned DatasetIterator will trigger execution of the lazy transformations performed on this dataset, and will block until execution completes.

Examples

>>> import ray
>>> for batch in ray.data.range(
...     1000000
... ).iterator().iter_batches(): 
...     print(batch) 

Note

It is recommended to use DatasetIterator methods over directly calling methods such as iter_batches().