Repeater¶
- class torchdata.datapipes.iter.Repeater(source_datapipe: IterDataPipe[T_co], times: int)¶
Repeatedly yield each element of source DataPipe for the specified number of times before moving onto the next element (functional name:
repeat). Note that no copy is made in this DataPipe, the same element is yielded repeatedly.If you would like to yield the whole DataPipe in order multiple times, use
Cycler.- Parameters:
source_datapipe – source DataPipe that will be iterated through
times – the number of times an element of
source_datapipewill be yielded before moving onto the next element
Example
>>> from torchdata.datapipes.iter import IterableWrapper >>> dp = IterableWrapper(range(3)) >>> dp = dp.repeat(2) >>> list(dp) [0, 0, 1, 1, 2, 2]