mindspore.dataset.Dataset.create_dict_iterator

Dataset.create_dict_iterator(num_epochs=- 1, output_numpy=False)[source]

Create an iterator over the dataset. The data retrieved will be a dictionary datatype.

Parameters
  • num_epochs (int, optional) – Maximum number of epochs that iterator can be iterated. Default: -1, iterator can be iterated infinite number of epochs.

  • output_numpy (bool, optional) – Whether or not to output NumPy datatype, if output_numpy=False, iterator will output MSTensor. Default: False.

Returns

Iterator, dictionary iterator over the dataset.

Examples

>>> # dataset is an instance object of Dataset
>>> iterator = dataset.create_dict_iterator()
>>> for item in iterator:
...     # item is a dict
...     print(type(item))
...     break
<class 'dict'>