Add documentation for trainer.datamodule and dataloaders of a trainer object (#14600)

* Update trainer.rst
* Update datamodule.rst
This commit is contained in:
Benjamin Krala 2022-09-14 17:46:34 +02:00 committed by GitHub
parent 32cb774a5c
commit c2378bd3b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 0 deletions

View File

@ -1597,6 +1597,16 @@ The number of epochs run.
if trainer.current_epoch >= 10:
...
datamodule
**********
The current datamodule, which is used by the trainer.
.. code-block:: python
used_datamodule = trainer.datamodule
is_last_batch
*************
@ -1694,6 +1704,17 @@ The metrics sent to the progress bar.
assert progress_bar_metrics["a_val"] == 2
predict_dataloaders
*******************
The current predict dataloaders of the trainer.
Note that property returns a list of predict dataloaders.
.. code-block:: python
used_predict_dataloaders = trainer.predict_dataloaders
estimated_stepping_batches
**************************
@ -1773,3 +1794,37 @@ both conditions are met. If any of these arguments is not set, it won't be consi
trainer = Trainer(min_steps=5, min_epochs=5, max_epochs=100)
model = LitModel()
trainer.fit(model)
train_dataloader
****************
The current train dataloader of the trainer.
.. code-block:: python
used_train_dataloader = trainer.train_dataloader
test_dataloaders
****************
The current test dataloaders of the trainer.
Note that property returns a list of test dataloaders.
.. code-block:: python
used_test_dataloaders = trainer.test_dataloaders
val_dataloaders
***************
The current val dataloaders of the trainer.
Note that property returns a list of val dataloaders.
.. code-block:: python
used_val_dataloaders = trainer.val_dataloaders

View File

@ -412,6 +412,10 @@ the method runs on the correct devices).
dm.setup(stage="test")
trainer.test(datamodule=dm)
You can access the current used datamodule of a trainer via ``trainer.datamodule`` and the current used
dataloaders via ``trainer.train_dataloader``, ``trainer.val_dataloaders`` and ``trainer.test_dataloaders``.
----------------
*****************************