Dynamic Dataloaders for on the fly modifications

If your use case allows to manipulate the dataset after a full epoch, I would recommend to perform the manipulations directly on the data inside the Dataset and just recreate the DataLoader.
Instantiation of DataLoaders should be cheap, so you shouldn’t see any slow down.

Also, manipulating the data on the fly inside a DataLoader loop might now work, if you are using multiple workers, so you would be forced to use num_workers=0 or use some shared memory approach.

2 Likes