2020-03-03 16:39:43 +00:00
|
|
|
r"""
|
|
|
|
Callback Base
|
2020-03-30 22:37:02 +00:00
|
|
|
=============
|
2020-03-03 16:39:43 +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-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-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-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
|