mindspore.dataset.Dataset.repeat

mindspore.dataset.Dataset.repeat(count=None)[源代码]

重复此数据集 count 次。如果 countNone-1 ,则无限重复迭代。

说明

repeat和batch的顺序反映了batch的数量。建议:repeat操作在batch操作之后使用。

参数:
  • count (int) - 数据集重复的次数。默认值: None

返回:

RepeatDataset,repeat操作后的数据集对象。

样例:

>>> import mindspore.dataset as ds
>>> dataset = ds.GeneratorDataset([i for i in range(10)], "column1")
>>>
>>> # Create a dataset where the dataset is repeated for 50 epochs
>>> dataset = dataset.repeat(50)
>>>
>>> # Create a dataset where each epoch is shuffled individually
>>> dataset = dataset.shuffle(10)
>>> dataset = dataset.repeat(50)
>>>
>>> # Create a dataset where the dataset is first repeated for
>>> # 50 epochs before shuffling. The shuffle operation will treat
>>> # the entire 50 epochs as one big dataset.
>>> dataset = dataset.repeat(50)
>>> dataset = dataset.shuffle(10)