Is it possible to change the batch_size of a dataloader after it was created?

Is this possible?
I’m asking this becasue for example today I had couple of models and for each of them I’d like to use a different batch_size, I initially created a dataloader with lets say batch_size of 32, and now I want to increase its size to lets say 128. but I dont want to create a new dataloader.
Is this possible?
I would appreciate any kind of help in this regard.

This shouldn’t be allowed in the current version anymore and you’ll get a ValueError:

ValueError: batch_size attribute should not be set after DataLoader is initialized

Creating a new DataLoader should be cheap, so I would recommend to initialize a new DataLoader.

2 Likes

Thanks, but why not?