Skip to content

Commit 2708c39

Browse files
meesawaelchli
andauthored
[doc] Improve Multiple Val/Test Dataloaders with simultaneous batches option (#6320)
* improve doc to describe how to combine batches of multiple test and val dataloaders simultaneously * fix typo Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com> * use paramref Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com> Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
1 parent 38a5fe7 commit 2708c39

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

docs/source/advanced/multiple_loaders.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ dataloaders).
6565

6666
However, with lightning you can also return multiple loaders and lightning will take care of batch combination.
6767

68-
For more details please have a look at :attr:`~pytorch_lightning.trainer.trainer.Trainer.multiple_trainloader_mode`
68+
For more details please have a look at :paramref:`~pytorch_lightning.trainer.trainer.Trainer.multiple_trainloader_mode`
6969

7070
.. testcode::
7171

@@ -114,9 +114,11 @@ be returned
114114
Test/Val dataloaders
115115
--------------------
116116
For validation and test dataloaders, lightning also gives you the additional
117-
option of passing multiple dataloaders back from each call.
117+
option of passing multiple dataloaders back from each call. You can choose to pass
118+
the batches sequentially or simultaneously, as is done for the training step.
119+
The default mode for validation and test dataloaders is sequential.
118120

119-
See the following for more details:
121+
See the following for more details for the default sequential option:
120122

121123
- :meth:`~pytorch_lightning.core.datamodule.LightningDataModule.val_dataloader`
122124
- :meth:`~pytorch_lightning.core.datamodule.LightningDataModule.test_dataloader`
@@ -127,3 +129,17 @@ See the following for more details:
127129
loader_1 = Dataloader()
128130
loader_2 = Dataloader()
129131
return [loader_1, loader_2]
132+
133+
To combine batches of multiple test and validation dataloaders simultaneously, one
134+
needs to wrap the dataloaders with `CombinedLoader`.
135+
136+
.. testcode::
137+
138+
from pytorch_lightning.trainer.supporters import CombinedLoader
139+
140+
def val_dataloader(self):
141+
loader_1 = Dataloader()
142+
loader_2 = Dataloader()
143+
loaders = {'a': loader_a,'b': loader_b}
144+
combined_loaders = CombinedLoader(loaders, "max_size_cycle")
145+
return combined_loaders

0 commit comments

Comments
 (0)