Skip to content

callback_hooks

BaseCallbackHook

Bases: abc.ABC

Source code in sequel/algos/utils/callback_hooks.py
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class BaseCallbackHook(abc.ABC):
    callbacks: List[BaseCallback] = []

    def on_before_setup_callbacks(self):
        """Callbacks before the setup."""
        for cb in self.callbacks:
            cb.on_before_setup(self)

    def on_after_setup_callbacks(self):
        """Callbacks after the setup."""
        for cb in self.callbacks:
            cb.on_after_setup(self)

    def on_before_teardown_callbacks(self):
        """Callbacks before the teardown."""
        for cb in self.callbacks:
            cb.on_before_teardown(self)

    def on_after_teardown_callbacks(self):
        """Callbacks after the teardown."""
        for cb in self.callbacks:
            cb.on_after_teardown(self)

    def on_before_fit_callbacks(self):
        """Callbacks before fitting the data."""
        for cb in self.callbacks:
            cb.on_before_fit(self)

    def on_after_fit_callbacks(self):
        """Callbacks after fitting the data."""
        for cb in self.callbacks:
            cb.on_after_fit(self)

    def on_before_training_task_callbacks(self):
        """Callbacks before training a single task."""
        for cb in self.callbacks:
            cb.on_before_training_task(self)

    def on_after_training_task_callbacks(self):
        """Callbacks after training a single task."""
        for cb in self.callbacks:
            cb.on_after_training_task(self)

    def on_before_training_epoch_callbacks(self):
        """Callbacks before training one epoch."""
        for cb in self.callbacks:
            cb.on_before_training_epoch(self)

    def on_after_training_epoch_callbacks(self):
        """Callbacks after training one epoch."""
        for cb in self.callbacks:
            cb.on_after_training_epoch(self)

    def on_before_val_epoch_callbacks(self):
        """Callbacks before validating one epoch."""
        for cb in self.callbacks:
            cb.on_before_val_epoch(self)

    def on_after_val_epoch_callbacks(self):
        """Callbacks after validating one epoch."""
        for cb in self.callbacks:
            cb.on_after_val_epoch(self)

    def on_before_val_step_callbacks(self):
        """Callbacks before the val step (single batch step)."""
        for cb in self.callbacks:
            cb.on_before_val_step(self)

    def on_after_val_step_callbacks(self):
        """Callbacks after the val step."""
        for cb in self.callbacks:
            cb.on_after_val_step(self)

    def on_before_training_step_callbacks(self):
        """Callbacks before the training step (single batch step)."""
        for cb in self.callbacks:
            cb.on_before_training_step(self)

    def on_after_training_step_callbacks(self):
        """Callbacks after the training step."""
        for cb in self.callbacks:
            cb.on_after_training_step(self)

    def on_before_backward_callbacks(self):
        """Callbacks before backpropagation."""
        for cb in self.callbacks:
            cb.on_before_backward(self)

    def on_after_backward_callbacks(self):
        """Callbacks after backpropagation."""
        for cb in self.callbacks:
            cb.on_after_backward(self)

    def on_before_optimizer_step_callbacks(self):
        """Callbacks before optimizer step."""
        for cb in self.callbacks:
            cb.on_before_optimizer_step(self)

    def on_after_optimizer_step_callbacks(self):
        """Callbacks after optimizer step."""
        for cb in self.callbacks:
            cb.on_after_optimizer_step(self)

    def on_before_validating_algorithm_on_all_tasks_callbacks(self):
        for cb in self.callbacks:
            cb.on_before_validating_algorithm_on_all_tasks(self)

    def on_after_validating_algorithm_on_all_tasks_callbacks(self):
        for cb in self.callbacks:
            cb.on_after_validating_algorithm_on_all_tasks(self)

on_after_backward_callbacks()

Callbacks after backpropagation.

Source code in sequel/algos/utils/callback_hooks.py
95
96
97
98
def on_after_backward_callbacks(self):
    """Callbacks after backpropagation."""
    for cb in self.callbacks:
        cb.on_after_backward(self)

on_after_fit_callbacks()

Callbacks after fitting the data.

Source code in sequel/algos/utils/callback_hooks.py
35
36
37
38
def on_after_fit_callbacks(self):
    """Callbacks after fitting the data."""
    for cb in self.callbacks:
        cb.on_after_fit(self)

on_after_optimizer_step_callbacks()

Callbacks after optimizer step.

Source code in sequel/algos/utils/callback_hooks.py
105
106
107
108
def on_after_optimizer_step_callbacks(self):
    """Callbacks after optimizer step."""
    for cb in self.callbacks:
        cb.on_after_optimizer_step(self)

on_after_setup_callbacks()

Callbacks after the setup.

Source code in sequel/algos/utils/callback_hooks.py
15
16
17
18
def on_after_setup_callbacks(self):
    """Callbacks after the setup."""
    for cb in self.callbacks:
        cb.on_after_setup(self)

on_after_teardown_callbacks()

Callbacks after the teardown.

Source code in sequel/algos/utils/callback_hooks.py
25
26
27
28
def on_after_teardown_callbacks(self):
    """Callbacks after the teardown."""
    for cb in self.callbacks:
        cb.on_after_teardown(self)

on_after_training_epoch_callbacks()

Callbacks after training one epoch.

Source code in sequel/algos/utils/callback_hooks.py
55
56
57
58
def on_after_training_epoch_callbacks(self):
    """Callbacks after training one epoch."""
    for cb in self.callbacks:
        cb.on_after_training_epoch(self)

on_after_training_step_callbacks()

Callbacks after the training step.

Source code in sequel/algos/utils/callback_hooks.py
85
86
87
88
def on_after_training_step_callbacks(self):
    """Callbacks after the training step."""
    for cb in self.callbacks:
        cb.on_after_training_step(self)

on_after_training_task_callbacks()

Callbacks after training a single task.

Source code in sequel/algos/utils/callback_hooks.py
45
46
47
48
def on_after_training_task_callbacks(self):
    """Callbacks after training a single task."""
    for cb in self.callbacks:
        cb.on_after_training_task(self)

on_after_val_epoch_callbacks()

Callbacks after validating one epoch.

Source code in sequel/algos/utils/callback_hooks.py
65
66
67
68
def on_after_val_epoch_callbacks(self):
    """Callbacks after validating one epoch."""
    for cb in self.callbacks:
        cb.on_after_val_epoch(self)

on_after_val_step_callbacks()

Callbacks after the val step.

Source code in sequel/algos/utils/callback_hooks.py
75
76
77
78
def on_after_val_step_callbacks(self):
    """Callbacks after the val step."""
    for cb in self.callbacks:
        cb.on_after_val_step(self)

on_before_backward_callbacks()

Callbacks before backpropagation.

Source code in sequel/algos/utils/callback_hooks.py
90
91
92
93
def on_before_backward_callbacks(self):
    """Callbacks before backpropagation."""
    for cb in self.callbacks:
        cb.on_before_backward(self)

on_before_fit_callbacks()

Callbacks before fitting the data.

Source code in sequel/algos/utils/callback_hooks.py
30
31
32
33
def on_before_fit_callbacks(self):
    """Callbacks before fitting the data."""
    for cb in self.callbacks:
        cb.on_before_fit(self)

on_before_optimizer_step_callbacks()

Callbacks before optimizer step.

Source code in sequel/algos/utils/callback_hooks.py
100
101
102
103
def on_before_optimizer_step_callbacks(self):
    """Callbacks before optimizer step."""
    for cb in self.callbacks:
        cb.on_before_optimizer_step(self)

on_before_setup_callbacks()

Callbacks before the setup.

Source code in sequel/algos/utils/callback_hooks.py
10
11
12
13
def on_before_setup_callbacks(self):
    """Callbacks before the setup."""
    for cb in self.callbacks:
        cb.on_before_setup(self)

on_before_teardown_callbacks()

Callbacks before the teardown.

Source code in sequel/algos/utils/callback_hooks.py
20
21
22
23
def on_before_teardown_callbacks(self):
    """Callbacks before the teardown."""
    for cb in self.callbacks:
        cb.on_before_teardown(self)

on_before_training_epoch_callbacks()

Callbacks before training one epoch.

Source code in sequel/algos/utils/callback_hooks.py
50
51
52
53
def on_before_training_epoch_callbacks(self):
    """Callbacks before training one epoch."""
    for cb in self.callbacks:
        cb.on_before_training_epoch(self)

on_before_training_step_callbacks()

Callbacks before the training step (single batch step).

Source code in sequel/algos/utils/callback_hooks.py
80
81
82
83
def on_before_training_step_callbacks(self):
    """Callbacks before the training step (single batch step)."""
    for cb in self.callbacks:
        cb.on_before_training_step(self)

on_before_training_task_callbacks()

Callbacks before training a single task.

Source code in sequel/algos/utils/callback_hooks.py
40
41
42
43
def on_before_training_task_callbacks(self):
    """Callbacks before training a single task."""
    for cb in self.callbacks:
        cb.on_before_training_task(self)

on_before_val_epoch_callbacks()

Callbacks before validating one epoch.

Source code in sequel/algos/utils/callback_hooks.py
60
61
62
63
def on_before_val_epoch_callbacks(self):
    """Callbacks before validating one epoch."""
    for cb in self.callbacks:
        cb.on_before_val_epoch(self)

on_before_val_step_callbacks()

Callbacks before the val step (single batch step).

Source code in sequel/algos/utils/callback_hooks.py
70
71
72
73
def on_before_val_step_callbacks(self):
    """Callbacks before the val step (single batch step)."""
    for cb in self.callbacks:
        cb.on_before_val_step(self)