2020-03-03 16:39:43 +00:00
|
|
|
r"""
|
|
|
|
Callback Base
|
2020-08-02 02:56:34 +00:00
|
|
|
-------------
|
2020-04-05 09:38:52 +00:00
|
|
|
|
|
|
|
Abstract base class used to build new callbacks.
|
|
|
|
|
2020-02-23 02:45:34 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
import abc
|
|
|
|
|
|
|
|
|
|
|
|
class Callback(abc.ABC):
|
2020-03-03 16:39:43 +00:00
|
|
|
r"""
|
|
|
|
Abstract base class used to build new callbacks.
|
|
|
|
"""
|
2020-02-23 02:45:34 +00:00
|
|
|
|
2020-06-18 11:21:44 +00:00
|
|
|
def setup(self, trainer, stage: str):
|
2020-06-17 23:49:58 +00:00
|
|
|
"""Called when fit or test begins"""
|
|
|
|
pass
|
|
|
|
|
2020-06-18 11:21:44 +00:00
|
|
|
def teardown(self, trainer, stage: str):
|
2020-06-17 23:49:58 +00:00
|
|
|
"""Called when fit or test ends"""
|
|
|
|
pass
|
|
|
|
|
2020-02-27 22:21:51 +00:00
|
|
|
def on_init_start(self, trainer):
|
2020-03-03 04:51:32 +00:00
|
|
|
"""Called when the trainer initialization begins, model has not yet been set."""
|
2020-02-27 22:21:51 +00:00
|
|
|
pass
|
2020-02-26 04:17:27 +00:00
|
|
|
|
2020-02-27 22:21:51 +00:00
|
|
|
def on_init_end(self, trainer):
|
2020-03-03 04:51:32 +00:00
|
|
|
"""Called when the trainer initialization ends, model has not yet been set."""
|
2020-02-26 04:17:27 +00:00
|
|
|
pass
|
2020-02-23 02:45:34 +00:00
|
|
|
|
2020-06-17 11:37:16 +00:00
|
|
|
def on_fit_start(self, trainer):
|
|
|
|
"""Called when fit begins"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_fit_end(self, trainer):
|
|
|
|
"""Called when fit ends"""
|
|
|
|
pass
|
|
|
|
|
2020-04-24 00:46:18 +00:00
|
|
|
def on_sanity_check_start(self, trainer, pl_module):
|
|
|
|
"""Called when the validation sanity check starts."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_sanity_check_end(self, trainer, pl_module):
|
|
|
|
"""Called when the validation sanity check ends."""
|
|
|
|
pass
|
|
|
|
|
2020-07-20 23:00:20 +00:00
|
|
|
def on_train_epoch_start(self, trainer, pl_module):
|
|
|
|
"""Called when the train epoch begins."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_train_epoch_end(self, trainer, pl_module):
|
|
|
|
"""Called when the train epoch ends."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_validation_epoch_start(self, trainer, pl_module):
|
|
|
|
"""Called when the val epoch begins."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_validation_epoch_end(self, trainer, pl_module):
|
|
|
|
"""Called when the val epoch ends."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_test_epoch_start(self, trainer, pl_module):
|
|
|
|
"""Called when the test epoch begins."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_test_epoch_end(self, trainer, pl_module):
|
|
|
|
"""Called when the test epoch ends."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_epoch_start(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the epoch begins."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_epoch_end(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the epoch ends."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_batch_start(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the training batch begins."""
|
|
|
|
pass
|
|
|
|
|
2020-04-24 00:46:18 +00:00
|
|
|
def on_validation_batch_start(self, trainer, pl_module):
|
|
|
|
"""Called when the validation batch begins."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_validation_batch_end(self, trainer, pl_module):
|
|
|
|
"""Called when the validation batch ends."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_test_batch_start(self, trainer, pl_module):
|
|
|
|
"""Called when the test batch begins."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_test_batch_end(self, trainer, pl_module):
|
|
|
|
"""Called when the test batch ends."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_batch_end(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the training batch ends."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_train_start(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the train begins."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_train_end(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the train ends."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_validation_start(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the validation loop begins."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_validation_end(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the validation loop ends."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_test_start(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the test begins."""
|
|
|
|
pass
|
|
|
|
|
2020-02-26 04:17:27 +00:00
|
|
|
def on_test_end(self, trainer, pl_module):
|
2020-02-23 02:45:34 +00:00
|
|
|
"""Called when the test ends."""
|
|
|
|
pass
|
2020-06-15 10:35:26 +00:00
|
|
|
|
|
|
|
def on_keyboard_interrupt(self, trainer, pl_module):
|
|
|
|
"""Called when the training is interrupted by KeyboardInterrupt."""
|