mindspore.dataset.Dataset.create_dict_iterator
- Dataset.create_dict_iterator(num_epochs=- 1, output_numpy=False, do_copy=False)[source]
Create an iterator over the dataset that yields samples of type dict, while the key is the column name and the value is the data.
- Parameters
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:False
.
- Returns
Iterator, a dataset iterator that yields samples of type dict.
Examples
>>> import mindspore.dataset as ds >>> >>> dataset = ds.GeneratorDataset([i for i in range(10)], "data") >>> num_epochs = 3 >>> iterator = dataset.create_dict_iterator(num_epochs=num_epochs) >>> for epoch in range(num_epochs): ... for item in iterator: ... # output is of type dict ... print(type(item)) ... break ... break <class 'dict'>