Toggling off 'shuffle' of a dataloader

I’d like to toggle off the shuffle attribute of a dataloader after certain point in my code. Can I do so without creating the dataloader again?

The shuffle argument determined which sampler will be created (RandomSampler or SequentialSampler as seen here) and is not directly used as an attribute in the DataLoader. For this reason I would not recommend to try to replace the internal sampler, but to recreate the DataLoader instead. If you are lazily loading the data in your Dataset, the initialization of the DataLoader should also be cheap.

1 Like