mindspore.dataset.Dataset.create_tuple_iterator
- Dataset.create_tuple_iterator(columns=None, num_epochs=- 1, output_numpy=False, do_copy=True)[source]
Create an iterator over the dataset that yields samples of type list, whose elements are the data for each column.
- Parameters
columns (list[str], optional) – Specify the output columns and the order. Default:
None
, keep all the output columns and their original order.num_epochs (int, optional) – The number of epochs to iterate over the entire dataset. Default:
-1
, the dataset can be iterated indefinitely.output_numpy (bool, optional) – Whether to keep the output data as NumPy ndarray, or convert it to Tensor. Default:
False
.do_copy (bool, optional) – Whether to copy the data when converting output to Tensor, or reuse the buffer for better performance, only works when output_numpy is
False
. Default:True
.
- Returns
Iterator, a dataset iterator that yields samples of type list.
Examples
>>> import mindspore.dataset as ds >>> >>> dataset = ds.GeneratorDataset([i for i in range(10)], "data") >>> num_epochs = 3 >>> iterator = dataset.create_tuple_iterator(num_epochs=num_epochs) >>> for epoch in range(num_epochs): ... for item in iterator: ... # output is of type tuple ... print(type(item)) ... break ... break <class 'list'>