noggin.logger.LiveLogger

class noggin.logger.LiveLogger(*args, **kwargs)[source]

Logs batch-level and epoch-level summary statistics of the training and testing metrics of a model during a session.

Examples

A simple example in which we log two iterations of training batches, and set an epoch.

>>> from noggin import LiveLogger
>>> logger = LiveLogger()
>>> logger.set_train_batch(dict(metric_a=2., metric_b=1.), batch_size=10)
>>> logger.set_train_batch(dict(metric_a=0., metric_b=2.), batch_size=4)
>>> logger.set_train_epoch()  # compute the mean statistics
>>> logger
LiveLogger(metric_a, metric_b)
number of training batches set: 2
number of training epochs set: 1
number of testing batches set: 0
number of testing epochs set: 0

Accessing our logged batch-level and epoch-level data

>>> logger.to_xarray("train")
MetricArrays(batch=<xarray.Dataset>
Dimensions:     (iterations: 2)
Coordinates:
  * iterations  (iterations) int32 1 2
Data variables:
    metric_a    (iterations) float64 2.0 0.0
    metric_b    (iterations) float64 1.0 2.0,
epoch=<xarray.Dataset>
Dimensions:     (iterations: 1)
Coordinates:
  * iterations  (iterations) int32 2
Data variables:
    metric_a    (iterations) float64 1.429
    metric_b    (iterations) float64 1.286)
Attributes:
test_metrics

The batch and epoch data for each test-metric.

train_metrics

The batch and epoch data for each train-metric.

Methods

from_dict(logger_dict, Any]) Records the state of the logger in a dictionary.
set_test_batch(metrics, numbers.Real], …) Record batch-level measurements for test-metrics.
set_test_epoch() Record an epoch for the test-metrics.
set_train_batch(metrics, numbers.Real], …) Record batch-level measurements for train-metrics.
set_train_epoch() Record an epoch for the train-metrics.
to_dict() Records the state of the logger in a dictionary.
to_xarray(train_or_test) Returns xarray datasets for the batch-level and epoch-level metrics, respectively, for either the train-metrics or test-metrics.
__init__(*args, **kwargs)[source]

LiveLogger.__init__ does not utilize any input arguments, but accepts *args, **kwargs so that it can be used as a drop-in replacement for

Methods

__init__(*args, **kwargs) LiveLogger.__init__ does not utilize any input arguments, but accepts *args, **kwargs so that it can be used as a drop-in replacement for LivePlot.
from_dict(logger_dict, Any]) Records the state of the logger in a dictionary.
set_test_batch(metrics, numbers.Real], …) Record batch-level measurements for test-metrics.
set_test_epoch() Record an epoch for the test-metrics.
set_train_batch(metrics, numbers.Real], …) Record batch-level measurements for train-metrics.
set_train_epoch() Record an epoch for the train-metrics.
to_dict() Records the state of the logger in a dictionary.
to_xarray(train_or_test) Returns xarray datasets for the batch-level and epoch-level metrics, respectively, for either the train-metrics or test-metrics.

Attributes

test_metrics The batch and epoch data for each test-metric.
train_metrics The batch and epoch data for each train-metric.