All data modules don't support providing batch size in the constructor. #417
Labels
bug
Something isn't working
datamodule
Anything related to datamodules
help wanted
Extra attention is needed
Milestone
🐛 Bug
Half of the data loaders don't support providing batch size in the constructor, but only in the
{train,val,test}_dataloader()
methods. This means that if a data module is passedTrainer.fit()
, the default batch size is used.Cifar10DataModule, CityscapesDataModule, ImagenetDataModule, KittiDataModule, and STL10DataModule take batch size in constructor, which is used by the
{train,val,test}_dataloader()
methods.MNISTDataModule takes batch size in constructor, but it's not used.
{train,val,test}_dataloader()
methods always use the default value 32.BinaryMNISTDataModule, FashionMNISTDataModule, SklearnDataModule, SSLImagenetDataModule, and VOCDetectionDataModule don't take batch size in constructor. These have
{train,val,test}_dataloader()
methods that take a batch size argument, but a trainer always calls them without arguments.To Reproduce
To illustrate the problem, the
--batch_size
argument has no effect in the the FasterRCNN model.Steps to reproduce the behavior:
print(batch_size)
toVOCDetectionDataModule.train_dataloader()
.python faster_rcnn.py --batch_size 10
.Expected behavior
The batch size argument should be passed in the dataloader calls. This could be fixed by calling
instead of
I guess it would be better to fix the data modules so that they take batch size in the constructor, though.
Environment
conda
,pip
, source): condaAdditional context
The DataModule documentation could be clearer regarding to how to set the batch size. The first MNISTDataModule example takes the batch size in constructor and saves it in the
batch_size
attribute, which is used by{train,val,test}_dataloader()
. In the second example, the{train,val,test}_dataloader()
methods take the batch size as an argument. However, ifTrainer.fit()
is called with a data module, the only way to set the batch size is in the data module constructor.The text was updated successfully, but these errors were encountered: