mindspore.dataset.Dataset.create_dict_iterator

View Source On Gitee
Dataset.create_dict_iterator(num_epochs=- 1, output_numpy=False, do_copy=True)[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 is False, iterator will output MSTensor. Default: False .

  • do_copy (bool, optional) – When output data type is mindspore.Tensor, use this param to select the conversion method, only take False for better performance. Default: True .

Returns

Iterator, a dataset iterator that returns data of type Dict.

Examples

>>> import mindspore.dataset as ds
>>> dataset = ds.GeneratorDataset([i for i in range(10)], "column1")
>>> iterator = dataset.create_dict_iterator()
>>> for item in iterator:
...     # item is a dict
...     print(type(item))
...     break
<class 'dict'>