BaseCallback#

class pyqit.core.callbacks.BaseCallback[source]#

Bases: _PyQitObject

Base class for pyqit callbacks.

Override any of the three hooks. Each takes one LoopState, and both training loops call them, so a subclass works on either backend.

Examples

>>> from pyqit.core import BaseCallback
>>> class StopWhenConverged(BaseCallback):
...     def on_epoch_end(self, state):
...         if state.metrics["train_loss"] < 0.01:
...             state.stop = True
classmethod get_test_params()[source]#

List constructor kwargs used to parametrize this class in the test suite.

on_epoch_end(state: LoopState) → None[source]#

Called once per epoch, with state.metrics filled for that epoch.

on_fit_end(state: LoopState) → None[source]#

Called once, after the last epoch, including after an early stop.

on_fit_start(state: LoopState) → None[source]#

Called once, after setup and before the first epoch.