mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-02 12:40:56 +08:00
* add argument to force warn * fix automodule error * fix permalink error * fix indentation warning * fix warning * fix import warnings * fix duplicate label warning * fix bullet point indentation warning * fix duplicate label warning * fix "import not top level" warning * line too long * fix indentation * fix bullet points indentation warning * fix hooks warnings * fix reference problem with excluded test_tube * fix indentation in print * change imports for trains logger * remove pandas type annotation * Update pytorch_lightning/core/lightning.py * include bullet points inside note * remove old quick start guide (unused) * fix unused warning * fix formatting * fix duplicate label issue * fix duplicate label warning (replaced by class ref) * fix tick * fix indentation warnings * docstring ticks * remove obsolete docstring typing * Revert "remove old quick start guide (unused)" This reverts commit d51bb40695442c8fa11bc9df74f6db56264f7509. * added old quick start guide to navigation * remove unused tutorials file * ignore some modules that got deprecated and are not used anymore * fix duplicate label warning * move examples doc and exclude pl_examples from autodoc * fix formatting for configure_optimizer * fix no blank line warnings * fix "see also" labels and add paramref extension * fix more reference problems * fix multi-gpu reference * fix weird warning * fix indentation and unrecognized characters in code block * fix warning "... not included in toctree" * fix PIL import error * fix duplicate target "here" warning * fix broken link * revert accidentally moved pl_examples * changelog * stdout * note some things to know Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com> Co-authored-by: J. Borovec <jirka.borovec@seznam.cz> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
79 lines
1.7 KiB
ReStructuredText
79 lines
1.7 KiB
ReStructuredText
.. role:: hidden
|
|
:class: hidden-section
|
|
|
|
.. _callbacks:
|
|
|
|
Callbacks
|
|
=========
|
|
|
|
Lightning has a callback system to execute arbitrary code. Callbacks should capture NON-ESSENTIAL
|
|
logic that is NOT required for your LightningModule to run.
|
|
|
|
An overall Lightning system should have:
|
|
|
|
1. Trainer for all engineering
|
|
2. LightningModule for all research code.
|
|
3. Callbacks for non-essential code.
|
|
|
|
Example
|
|
|
|
.. code-block:: python
|
|
|
|
import pytorch_lightning as pl
|
|
|
|
class MyPrintingCallback(pl.Callback):
|
|
|
|
def on_init_start(self, trainer):
|
|
print('Starting to init trainer!')
|
|
|
|
def on_init_end(self, trainer):
|
|
print('trainer is init now')
|
|
|
|
def on_train_end(self, trainer, pl_module):
|
|
print('do something when training ends')
|
|
|
|
# pass to trainer
|
|
trainer = pl.Trainer(callbacks=[MyPrintingCallback()])
|
|
|
|
We successfully extended functionality without polluting our super clean LightningModule research code
|
|
|
|
---------
|
|
|
|
.. automodule:: pytorch_lightning.callbacks.base
|
|
:noindex:
|
|
:exclude-members:
|
|
_del_model,
|
|
_save_model,
|
|
_abc_impl,
|
|
check_monitor_top_k,
|
|
|
|
---------
|
|
|
|
.. automodule:: pytorch_lightning.callbacks.early_stopping
|
|
:noindex:
|
|
:exclude-members:
|
|
_del_model,
|
|
_save_model,
|
|
_abc_impl,
|
|
check_monitor_top_k,
|
|
|
|
---------
|
|
|
|
.. automodule:: pytorch_lightning.callbacks.model_checkpoint
|
|
:noindex:
|
|
:exclude-members:
|
|
_del_model,
|
|
_save_model,
|
|
_abc_impl,
|
|
check_monitor_top_k,
|
|
|
|
---------
|
|
|
|
.. automodule:: pytorch_lightning.callbacks.gradient_accumulation_scheduler
|
|
:noindex:
|
|
:exclude-members:
|
|
_del_model,
|
|
_save_model,
|
|
_abc_impl,
|
|
check_monitor_top_k,
|