LoggingCallback

class hybrid_learning.concepts.train_eval.callbacks.LoggingCallback(logger=None, log_level=20, log_per_batch=False)[source]

Bases: Callback

Log batch and epoch KPI results.

Public Methods:

after_batch_train(kpi_train, batch, batches)

Logging of training KPI values after one batch.

after_epoch(kpi_train, kpi_val[, logger, ...])

Logging of mean training and validation KPI values after one epoch.

Inherited from : py: class:Callback

keys()

Collect a list of all supported callback events.

Inherited from : py: class:Mapping

get(k[,d])

keys()

Collect a list of all supported callback events.

items()

values()

Special Methods:

__init__([logger, log_level, log_per_batch])

Inherited from : py: class:Callback

__getitem__(event)

Get the method for the specified event or a pass lambda.

__len__()

Number of mapped events.

__iter__()

Iterate over mapped events.

Inherited from : py: class:Mapping

__getitem__(event)

Get the method for the specified event or a pass lambda.

__contains__(key)

__eq__(other)

Return self==value.

Inherited from : py: class:Sized

__len__()

Number of mapped events.

Inherited from : py: class:Iterable

__iter__()

Iterate over mapped events.

Inherited from : py: class:Container

__contains__(key)


__init__(logger=None, log_level=20, log_per_batch=False)[source]
Parameters
after_batch_train(kpi_train, batch, batches, epoch=None, epochs=None, run=None, runs=None, batch_info_templ=None, log_prefix='', logger=None, **_unused_args)[source]

Logging of training KPI values after one batch.

Parameters
  • batch (int) – the current batch index

  • epoch (Optional[int]) – the current epoch index

  • run (Optional[int]) – the current cross-validation run index

  • batches (int) – the total number of batches

  • epochs (Optional[int]) – the total number of epochs

  • runs (Optional[int]) – the total number of cross-validation runs

  • log_prefix (str) – text to prepend to log messages

  • batch_info_templ (Optional[str]) –

    string template for logging epoch and batch, which may include as substring

    • {run}/{epoch}/{batch}: the current cross-validation run/epoch/batch number

    • {runs}/{epochs}/{batches}: the total number of cross-validation runs/epochs/batches

  • kpi_train (DataFrame) – pandas.Series indexed by the KPI names for training with the KPI values over the last training batch

  • logger (Optional[Logger]) – do not use this instances logger but a different one

Return type

None

after_epoch(kpi_train, kpi_val, logger=None, log_prefix='', **_unused_args)[source]

Logging of mean training and validation KPI values after one epoch.

Parameters
  • kpi_train (DataFrame) – pandas.Series indexed by the KPI names for training with the mean KPI values over the last training epoch

  • kpi_val (Series) – pandas.Series indexed by the KPI names for testing with the KPI values over the validation set after the epoch

  • log_prefix (str) – text to prepend to log messages

  • logger (Optional[Logger]) – do not use this instances logger but a different one

Return type

None

__parameters__ = ()
log_level: int

The logging level to use. Defaults to logging.INFO.

log_per_batch: int

Log after each ith batch. If set to False or 0 don’t log batches at all, if True or 1 log each batch.

logger: Optional[Logger]

The default logger to use.