clarena.callbacks.pylogger

The submodule in callbacks for Pylogger callbacks.

  1r"""
  2The submodule in `callbacks` for Pylogger callbacks.
  3"""
  4
  5__all__ = ["CLPylogger", "CULPylogger", "MTLPylogger", "STLPylogger"]
  6
  7import logging
  8
  9from lightning import Callback, Trainer
 10
 11from clarena.cl_algorithms import CLAlgorithm
 12from clarena.mtl_algorithms import MTLAlgorithm
 13from clarena.stl_algorithms import STLAlgorithm
 14
 15# always get logger for built-in logging in each module
 16pylogger = logging.getLogger(__name__)
 17
 18
 19class CLPylogger(Callback):
 20    r"""Provides additional logging messages for during continual learning progress.
 21
 22    Put logging messages here if you don't want to mess up the `CLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
 23    """
 24
 25    def on_fit_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 26        r"""Log messages for the start of training task."""
 27        pylogger.info("Start training continual learning task %s!", pl_module.task_id)
 28
 29    def on_train_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 30        r"""Log messages for the end of training task."""
 31        pylogger.info("Finish training continual learning task %s!", pl_module.task_id)
 32
 33    def on_test_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 34        r"""Log messages for the start of testing task."""
 35        pylogger.info(
 36            "Start testing continual learning task %s on all previous and current tasks!",
 37            pl_module.task_id,
 38        )
 39
 40    def on_test_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 41        r"""Log messages for the end of testing task."""
 42        pylogger.info(
 43            "Finish testing continual learning task %s on all previous and current tasks!",
 44            pl_module.task_id,
 45        )
 46
 47
 48class CULPylogger(Callback):
 49    r"""Provides additional logging messages for during continual learning progress.
 50
 51    Put logging messages here if you don't want to mess up the `CLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
 52    """
 53
 54    def on_fit_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 55        r"""Log messages for the start of training task."""
 56        pylogger.info("Start training continual learning task %s!", pl_module.task_id)
 57
 58    def on_train_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 59        r"""Log messages for the end of training task."""
 60        pylogger.info("Finish training continual learning task %s!", pl_module.task_id)
 61
 62    def on_test_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 63        r"""Log messages for the start of testing task."""
 64        pylogger.info(
 65            "Start testing continual learning task %s on all previous and current tasks!",
 66            pl_module.task_id,
 67        )
 68
 69    def on_test_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
 70        r"""Log messages for the end of testing task."""
 71        pylogger.info(
 72            "Finish testing continual learning task %s on all previous and current tasks!",
 73            pl_module.task_id,
 74        )
 75
 76
 77class MTLPylogger(Callback):
 78    r"""Pylogger Callback provides additional logging for during multi-task learning progress.
 79
 80    Put logging messages here if you don't want to mess up the `MTLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
 81    """
 82
 83    def on_fit_start(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
 84        r"""Log messages for the start of training."""
 85        pylogger.info("Start multi-task training!")
 86
 87    def on_train_end(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
 88        r"""Log messages for the end of training."""
 89        pylogger.info("Finish multi-task training!")
 90
 91    def on_test_start(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
 92        r"""Log messages for the start of testing."""
 93        pylogger.info("Start testing multi-task testing!")
 94
 95    def on_test_end(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
 96        r"""Log messages for the end of testing."""
 97        pylogger.info("Finish testing multi-task testing!")
 98
 99
100class STLPylogger(Callback):
101    r"""Pylogger Callback provides additional logging for during single-task learning progress.
102
103    Put logging messages here if you don't want to mess up the `STLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
104    """
105
106    def on_fit_start(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
107        r"""Log messages for the start of training."""
108        pylogger.info("Start single-task training!")
109
110    def on_train_end(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
111        r"""Log messages for the end of training."""
112        pylogger.info("Finish single-task training!")
113
114    def on_test_start(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
115        r"""Log messages for the start of testing."""
116        pylogger.info("Start single-task testing!")
117
118    def on_test_end(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
119        r"""Log messages for the end of testing."""
120        pylogger.info("Finish single-task testing!")
class CLPylogger(lightning.pytorch.callbacks.callback.Callback):
20class CLPylogger(Callback):
21    r"""Provides additional logging messages for during continual learning progress.
22
23    Put logging messages here if you don't want to mess up the `CLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
24    """
25
26    def on_fit_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
27        r"""Log messages for the start of training task."""
28        pylogger.info("Start training continual learning task %s!", pl_module.task_id)
29
30    def on_train_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
31        r"""Log messages for the end of training task."""
32        pylogger.info("Finish training continual learning task %s!", pl_module.task_id)
33
34    def on_test_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
35        r"""Log messages for the start of testing task."""
36        pylogger.info(
37            "Start testing continual learning task %s on all previous and current tasks!",
38            pl_module.task_id,
39        )
40
41    def on_test_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
42        r"""Log messages for the end of testing task."""
43        pylogger.info(
44            "Finish testing continual learning task %s on all previous and current tasks!",
45            pl_module.task_id,
46        )

Provides additional logging messages for during continual learning progress.

Put logging messages here if you don't want to mess up the CLAlgorithm (LightningModule) with a huge amount of logging codes.

def on_fit_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
26    def on_fit_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
27        r"""Log messages for the start of training task."""
28        pylogger.info("Start training continual learning task %s!", pl_module.task_id)

Log messages for the start of training task.

def on_train_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
30    def on_train_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
31        r"""Log messages for the end of training task."""
32        pylogger.info("Finish training continual learning task %s!", pl_module.task_id)

Log messages for the end of training task.

def on_test_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
34    def on_test_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
35        r"""Log messages for the start of testing task."""
36        pylogger.info(
37            "Start testing continual learning task %s on all previous and current tasks!",
38            pl_module.task_id,
39        )

Log messages for the start of testing task.

def on_test_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
41    def on_test_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
42        r"""Log messages for the end of testing task."""
43        pylogger.info(
44            "Finish testing continual learning task %s on all previous and current tasks!",
45            pl_module.task_id,
46        )

Log messages for the end of testing task.

class CULPylogger(lightning.pytorch.callbacks.callback.Callback):
49class CULPylogger(Callback):
50    r"""Provides additional logging messages for during continual learning progress.
51
52    Put logging messages here if you don't want to mess up the `CLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
53    """
54
55    def on_fit_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
56        r"""Log messages for the start of training task."""
57        pylogger.info("Start training continual learning task %s!", pl_module.task_id)
58
59    def on_train_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
60        r"""Log messages for the end of training task."""
61        pylogger.info("Finish training continual learning task %s!", pl_module.task_id)
62
63    def on_test_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
64        r"""Log messages for the start of testing task."""
65        pylogger.info(
66            "Start testing continual learning task %s on all previous and current tasks!",
67            pl_module.task_id,
68        )
69
70    def on_test_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
71        r"""Log messages for the end of testing task."""
72        pylogger.info(
73            "Finish testing continual learning task %s on all previous and current tasks!",
74            pl_module.task_id,
75        )

Provides additional logging messages for during continual learning progress.

Put logging messages here if you don't want to mess up the CLAlgorithm (LightningModule) with a huge amount of logging codes.

def on_fit_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
55    def on_fit_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
56        r"""Log messages for the start of training task."""
57        pylogger.info("Start training continual learning task %s!", pl_module.task_id)

Log messages for the start of training task.

def on_train_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
59    def on_train_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
60        r"""Log messages for the end of training task."""
61        pylogger.info("Finish training continual learning task %s!", pl_module.task_id)

Log messages for the end of training task.

def on_test_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
63    def on_test_start(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
64        r"""Log messages for the start of testing task."""
65        pylogger.info(
66            "Start testing continual learning task %s on all previous and current tasks!",
67            pl_module.task_id,
68        )

Log messages for the start of testing task.

def on_test_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.cl_algorithms.CLAlgorithm) -> None:
70    def on_test_end(self, trainer: Trainer, pl_module: CLAlgorithm) -> None:
71        r"""Log messages for the end of testing task."""
72        pylogger.info(
73            "Finish testing continual learning task %s on all previous and current tasks!",
74            pl_module.task_id,
75        )

Log messages for the end of testing task.

class MTLPylogger(lightning.pytorch.callbacks.callback.Callback):
78class MTLPylogger(Callback):
79    r"""Pylogger Callback provides additional logging for during multi-task learning progress.
80
81    Put logging messages here if you don't want to mess up the `MTLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
82    """
83
84    def on_fit_start(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
85        r"""Log messages for the start of training."""
86        pylogger.info("Start multi-task training!")
87
88    def on_train_end(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
89        r"""Log messages for the end of training."""
90        pylogger.info("Finish multi-task training!")
91
92    def on_test_start(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
93        r"""Log messages for the start of testing."""
94        pylogger.info("Start testing multi-task testing!")
95
96    def on_test_end(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
97        r"""Log messages for the end of testing."""
98        pylogger.info("Finish testing multi-task testing!")

Pylogger Callback provides additional logging for during multi-task learning progress.

Put logging messages here if you don't want to mess up the MTLAlgorithm (LightningModule) with a huge amount of logging codes.

def on_fit_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.mtl_algorithms.MTLAlgorithm) -> None:
84    def on_fit_start(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
85        r"""Log messages for the start of training."""
86        pylogger.info("Start multi-task training!")

Log messages for the start of training.

def on_train_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.mtl_algorithms.MTLAlgorithm) -> None:
88    def on_train_end(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
89        r"""Log messages for the end of training."""
90        pylogger.info("Finish multi-task training!")

Log messages for the end of training.

def on_test_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.mtl_algorithms.MTLAlgorithm) -> None:
92    def on_test_start(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
93        r"""Log messages for the start of testing."""
94        pylogger.info("Start testing multi-task testing!")

Log messages for the start of testing.

def on_test_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.mtl_algorithms.MTLAlgorithm) -> None:
96    def on_test_end(self, trainer: Trainer, pl_module: MTLAlgorithm) -> None:
97        r"""Log messages for the end of testing."""
98        pylogger.info("Finish testing multi-task testing!")

Log messages for the end of testing.

class STLPylogger(lightning.pytorch.callbacks.callback.Callback):
101class STLPylogger(Callback):
102    r"""Pylogger Callback provides additional logging for during single-task learning progress.
103
104    Put logging messages here if you don't want to mess up the `STLAlgorithm` (`LightningModule`) with a huge amount of logging codes.
105    """
106
107    def on_fit_start(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
108        r"""Log messages for the start of training."""
109        pylogger.info("Start single-task training!")
110
111    def on_train_end(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
112        r"""Log messages for the end of training."""
113        pylogger.info("Finish single-task training!")
114
115    def on_test_start(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
116        r"""Log messages for the start of testing."""
117        pylogger.info("Start single-task testing!")
118
119    def on_test_end(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
120        r"""Log messages for the end of testing."""
121        pylogger.info("Finish single-task testing!")

Pylogger Callback provides additional logging for during single-task learning progress.

Put logging messages here if you don't want to mess up the STLAlgorithm (LightningModule) with a huge amount of logging codes.

def on_fit_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.stl_algorithms.STLAlgorithm) -> None:
107    def on_fit_start(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
108        r"""Log messages for the start of training."""
109        pylogger.info("Start single-task training!")

Log messages for the start of training.

def on_train_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.stl_algorithms.STLAlgorithm) -> None:
111    def on_train_end(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
112        r"""Log messages for the end of training."""
113        pylogger.info("Finish single-task training!")

Log messages for the end of training.

def on_test_start( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.stl_algorithms.STLAlgorithm) -> None:
115    def on_test_start(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
116        r"""Log messages for the start of testing."""
117        pylogger.info("Start single-task testing!")

Log messages for the start of testing.

def on_test_end( self, trainer: lightning.pytorch.trainer.trainer.Trainer, pl_module: clarena.stl_algorithms.STLAlgorithm) -> None:
119    def on_test_end(self, trainer: Trainer, pl_module: STLAlgorithm) -> None:
120        r"""Log messages for the end of testing."""
121        pylogger.info("Finish single-task testing!")

Log messages for the end of testing.