From 1d11f61c36b5544597c0bbcd3f652729973c85df Mon Sep 17 00:00:00 2001 From: William Falcon Date: Tue, 3 Mar 2020 11:39:43 -0500 Subject: [PATCH] Docs2 (#1028) * added community examples * added community examples --- docs/source/callbacks.rst | 27 ++++++++++++++++--- pytorch_lightning/callbacks/base.py | 13 ++++----- pytorch_lightning/callbacks/early_stopping.py | 8 +++++- .../gradient_accumulation_scheduler.py | 6 +++++ .../callbacks/model_checkpoint.py | 7 +++++ 5 files changed, 51 insertions(+), 10 deletions(-) diff --git a/docs/source/callbacks.rst b/docs/source/callbacks.rst index fdea9665..fe2bf2ec 100644 --- a/docs/source/callbacks.rst +++ b/docs/source/callbacks.rst @@ -35,10 +35,31 @@ Example We successfully extended functionality without polluting our super clean LightningModule research code -Callback Class --------------- +.. automodule:: pytorch_lightning.callbacks.base + :noindex: + :exclude-members: + _del_model, + _save_model, + _abc_impl, + check_monitor_top_k, -.. automodule:: pytorch_lightning.callbacks +.. 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, diff --git a/pytorch_lightning/callbacks/base.py b/pytorch_lightning/callbacks/base.py index 6f04edbb..003241b2 100644 --- a/pytorch_lightning/callbacks/base.py +++ b/pytorch_lightning/callbacks/base.py @@ -1,15 +1,16 @@ -""" -Callbacks -========= - -Callbacks supported by Lightning +r""" +Callback Base +============== + Abstract base class used to build new callbacks. """ import abc class Callback(abc.ABC): - """Abstract base class used to build new callbacks.""" + r""" + Abstract base class used to build new callbacks. + """ def on_init_start(self, trainer): """Called when the trainer initialization begins, model has not yet been set.""" diff --git a/pytorch_lightning/callbacks/early_stopping.py b/pytorch_lightning/callbacks/early_stopping.py index 10823e95..1d976cec 100644 --- a/pytorch_lightning/callbacks/early_stopping.py +++ b/pytorch_lightning/callbacks/early_stopping.py @@ -1,3 +1,10 @@ +r""" +Early Stopping +============== +Stop training when a monitored quantity has stopped improving. + +""" + import logging as log import warnings @@ -8,7 +15,6 @@ from .base import Callback class EarlyStopping(Callback): r""" - Stop training when a monitored quantity has stopped improving. Args: monitor (str): quantity to be monitored. Default: ``'val_loss'``. diff --git a/pytorch_lightning/callbacks/gradient_accumulation_scheduler.py b/pytorch_lightning/callbacks/gradient_accumulation_scheduler.py index 9662c0b4..fcb9b152 100644 --- a/pytorch_lightning/callbacks/gradient_accumulation_scheduler.py +++ b/pytorch_lightning/callbacks/gradient_accumulation_scheduler.py @@ -1,3 +1,9 @@ +r""" +Gradient Accumulator +==================== +Change gradient accumulation factor according to scheduling. +""" + import warnings from .base import Callback diff --git a/pytorch_lightning/callbacks/model_checkpoint.py b/pytorch_lightning/callbacks/model_checkpoint.py index b3509fb6..8388c5c4 100644 --- a/pytorch_lightning/callbacks/model_checkpoint.py +++ b/pytorch_lightning/callbacks/model_checkpoint.py @@ -1,3 +1,10 @@ +r""" +Model Checkpoint +============== +Save the model as often as requested. + +""" + import os import shutil import logging as log