Shortcuts

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')
# download data and setup dataloaders
dm.prepare_data()
dm.setup()
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

Read the Docs v: 0.4.0
Versions
latest
stable
0.4.0
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.1
docs-build-rtd
0.1.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.