Shuffle¶
- class torchdata.dataloader2.adapter.Shuffle(enable=True)¶
Shuffle DataPipes adapter allows control over all existing Shuffler (
shuffle
) DataPipes in the graph.- Parameters:
enable –
Optional boolean argument to enable/disable shuffling in the
DataPipe
graph. True by default.True: Enables all previously disabled
ShufflerDataPipes
. If none exists, it will add a newshuffle
at the end of the graph.False: Disables all
ShufflerDataPipes
in the graph.None: No-op. Introduced for backward compatibility.
Example
>>> dp = IterableWrapper(range(size)).shuffle() >>> dl = DataLoader2(dp, [Shuffle(False)]) >>> self.assertEqual(list(range(size)), list(dl))