Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 845 Bytes

datamodules.rst

File metadata and controls

36 lines (26 loc) · 845 Bytes

DataModules

DataModules (introduced in PyTorch Lightning 0.9.0) decouple the data from a model. A DataModule is simply a collection of a training dataloder, val dataloader and test dataloader. In addition, it specifies how to:

  • Download/prepare data.
  • Train/val/test splits.
  • Transform

Then you can use it like this:

Example:

dm = MNISTDataModule('path/to/data')
model = LitModel()

trainer = Trainer()
trainer.fit(model, datamodule=dm)

Or use it manually with plain PyTorch

Example:

dm = MNISTDataModule('path/to/data')
for batch in dm.train_dataloader():
    ...
for batch in dm.val_dataloader():
    ...
for batch in dm.test_dataloader():
    ...

Please visit the PyTorch Lightning documentation for more details on DataModules