You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/extensions/loops.rst
+24-9Lines changed: 24 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -411,18 +411,33 @@ To run the following demo, install Flash and `BaaL <https://github.com/ElementAI
411
411
Here is the `Active Learning Loop example <https://github.com/PyTorchLightning/lightning-flash/blob/master/flash_examples/integrations/baal/image_classification_active_learning.py>`_ and the `code for the active learning loop <https://github.com/PyTorchLightning/lightning-flash/blob/master/flash/image/classification/integrations/baal/loop.py#L31>`_.
412
412
413
413
414
-
`KFold / Cross Validation <https://en.wikipedia.org/wiki/Cross-validation_(statistics)>`__ is a machine learning practice in which the training dataset is being partitioned into `num_folds` complementary subsets.
415
-
One cross validation round will perform fitting where one fold is left out for validation and the other folds are used for training.
416
-
To reduce variability, once all rounds are performed using the different folds, the trained models are ensembled and their predictions are
417
-
averaged when estimating the model's predictive performance on the test dataset.
418
-
KFold can elegantly be implemented with `Lightning Loop Customization` as follows:
414
+
----------
415
+
416
+
Advanced Examples
417
+
-----------------
418
+
419
+
420
+
.. list-table:: Ready-to-run loop examples and tutorials
421
+
:widths: 25 75
422
+
:header-rows: 1
419
423
420
-
Here is the `KFold Loop example <https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pl_examples/loops/kfold.py>`_.
- `KFold / Cross Validation <https://en.wikipedia.org/wiki/Cross-validation_(statistics)>`__ is a machine learning practice in which the training dataset is being partitioned into ``num_folds`` complementary subsets.
428
+
One cross validation round will perform fitting where one fold is left out for validation and the other folds are used for training.
429
+
To reduce variability, once all rounds are performed using the different folds, the trained models are ensembled and their predictions are
430
+
averaged when estimating the model's predictive performance on the test dataset.
431
+
* - `Yielding Training Step <https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pl_examples/loop_examples/yielding_training_step.py>`_
432
+
- This loop enables you to write the :meth:`~pytorch_lightning.core.lightning.LightningModule.training_step` hook
433
+
as a Python Generator for automatic optimization with multiple optimizers, i.e., you can :code:`yield` loss
434
+
values from it instead of returning them. This can enable more elegant and expressive implementations, as shown
435
+
shown with a GAN in this example.
421
436
422
437
423
438
----------
424
439
425
-
Advanced Topics and Examples
426
-
----------------------------
440
+
Advanced Features
441
+
-----------------
427
442
428
-
Next: :doc:`Advanced loop features and examples <../extensions/loops_advanced>`
443
+
Next: :doc:`Advanced loop features <../extensions/loops_advanced>`
Contains implementations leveraging [loop customization](https://pytorch-lightning.readthedocs.io/en/latest/extensions/loops.html) to enhance the Trainer with new optimization routines.
29
+
30
+
-[K-fold Cross Validation Loop](./loop_examples/kfold.py): Implemenation of cross validation in a loop and special datamodule.
31
+
-[Yield Loop](./loop_examples/yielding_training_step.py): Enables yielding from the training_step like in a Python generator. Useful for automatic optimization with multiple optimizers.
0 commit comments