Cerebras Model Zoo Loggers#

This module contains the base Logger class as well as a few useful Logger subclasses.

class cerebras.modelzoo.trainer.loggers.Logger[source]#

Bases: cerebras.modelzoo.trainer.callbacks.callback.Callback, abc.ABC

Base class for logging metrics to different backends.

It is a simple subclass of Callback that features one additional abstract method log which needs to be implemented by the derived classes.

flush()[source]#

Manually flush the logger.

abstract log_metrics(metrics, step)[source]#

Logs the metrics to the backend at the given step.

Parameters
  • metrics (dict) – Dictionary containing the metrics to be logged.

  • step (int) – The current step number.

Loggers#

The Logger subclasses available out-of-the-box.

ProgressLogger#

class cerebras.modelzoo.trainer.loggers.ProgressLogger[source]#

Bases: cerebras.modelzoo.trainer.loggers.logger.Logger

Callback that handles setting up and logging to the standard Python logger.

Sets up the rate tracker and total samples tracker.

static format_rate(rate)[source]#

Format the rate for logging.

Use two significant digits if the rate is less than 1.0, otherwise use two decimal places.

Parameters

rate (float) – Rate to format.

property postfix: List[str]#

Returns the postfix to append to the progress message.

print_training_progress(trainer, loss, batch_size)[source]#

Print training progress and log metrics.

print_validation_progress(trainer, loss, batch_size)[source]#

Print validation progress and log metrics.

TensorBoardLogger#

class cerebras.modelzoo.trainer.loggers.TensorBoardLogger(summary_dir=None, legacy_event_dirs=False)[source]#

Bases: cerebras.modelzoo.trainer.loggers.logger.Logger

Logger class that logs metrics to Tensorboard.

Parameters
  • summary_dir (Optional[str]) – Directory to save the Tensorboard logs. If None, use the trainer’s model_dir.

  • legacy_event_dirs (bool) – If True, use the legacy directory structure for event files. This option exists to maintain some backwards compatibility and should not be set to True or relied on if at all possible.

setup_writer(trainer, mode=None)[source]#

Set up the writer in a context manager.

The writer gets flushed on exit.