Skip to content

Commit c15d70e

Browse files
committed
enhance docs for val_check_interval
1 parent a758d90 commit c15d70e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/source/common/trainer.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,8 @@ How often within one training epoch to check the validation set.
15321532
Can specify as float or int.
15331533

15341534
- pass a ``float`` in the range [0.0, 1.0] to check after a fraction of the training epoch.
1535-
- pass an ``int`` to check after a fixed number of training batches.
1535+
- pass an ``int`` to check after a fixed number of training batches. An ``int`` value can only be higher than the number of training
1536+
batches when ``check_val_every_n_epoch=None``, which validates after every ``N`` training batches across complete training.
15361537

15371538
.. testcode::
15381539

@@ -1542,10 +1543,13 @@ Can specify as float or int.
15421543
# check validation set 4 times during a training epoch
15431544
trainer = Trainer(val_check_interval=0.25)
15441545

1545-
# check validation set every 1000 training batches
1546+
# check validation set every 1000 training batches in the current epoch
1547+
trainer = Trainer(val_check_interval=1000)
1548+
1549+
# check validation set every 1000 training batches across complete training
15461550
# use this when using iterableDataset and your dataset has no length
15471551
# (ie: production cases with streaming data)
1548-
trainer = Trainer(val_check_interval=1000)
1552+
trainer = Trainer(val_check_interval=1000, check_val_every_n_epoch=None)
15491553

15501554

15511555
.. code-block:: python

pytorch_lightning/trainer/trainer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ def __init__(
405405
val_check_interval: How often to check the validation set. Pass a ``float`` in the range [0.0, 1.0] to check
406406
after a fraction of the training epoch. Pass an ``int`` to check after a fixed number of training
407407
batches. An ``int`` value can only be higher than the number of training batches when
408-
``check_val_every_n_epoch=None``.
408+
``check_val_every_n_epoch=None``, which validates after every ``N`` training batches across complete
409+
training.
409410
Default: ``1.0``.
410411
411412
enable_model_summary: Whether to enable model summarization by default.

0 commit comments

Comments
 (0)