composer.loggers.logger#

Base classes, functions, and variables for logger.

Functions

format_log_data_value

Recursively formats a given log data value into a string.

Classes

LogLevel

LogLevel denotes when in the training loop log messages are generated.

Logger

An interface to record training data.

class composer.loggers.logger.LogLevel(value)[source]#

Bases: enum.IntEnum

LogLevel denotes when in the training loop log messages are generated.

Logging destinations use the LogLevel to determine whether to record a given metric or state change. .. attribute:: FIT

Logged once per training run.

EPOCH#

Logged once per epoch.

BATCH#

Logged once per batch.

class composer.loggers.logger.Logger(state, destinations=None, run_name=None)[source]#

An interface to record training data.

The Trainer, instances of Callback, and instances of Algorithm invoke the logger to record data such as the epoch, training loss, and custom metrics as provided by individual callbacks and algorithms. This class does not store any data itself; instead, it routes all data to the destinations. Each destination (e.g. the FileLogger, InMemoryLogger) is responsible for storing the data itself (e.g. writing it to a file or storing it in memory).

Parameters
  • state (State) โ€“ The training state.

  • destinations (LoggerDestination | Sequence[LoggerDestination], optional) โ€“ The logger destinations, to where logging data will be sent. (default: None)

  • run_name (str, optional) โ€“

    The name for this training run.

    If not specified, the timestamp will be combined with a coolname like the following:

    >>> logger = Logger(state=state, destinations=[])
    >>> logger.run_name
    '1647293526-electric-zebra'
    

destinations#

A sequence of LoggerDestination to where logging calls will be sent.

Type

Sequence[LoggerDestination]

run_name#

The run_name.

Type

str

data(log_level, data)[source]#

Log data to the destinations.

Parameters
  • log_level (str | int | LogLevel) โ€“ The log level, which can be a name, value, or instance of LogLevel.

  • data (Dict[str, Any]) โ€“ The data to log.

data_batch(data)[source]#

Helper function for self.data(LogLevel.BATCH, data)

data_epoch(data)[source]#

Helper function for self.data(LogLevel.EPOCH, data)

data_fit(data)[source]#

Helper function for self.data(LogLevel.FIT, data)

file_artifact(log_level, artifact_name, file_path, *, overwrite=False)[source]#

Log file_path as an artifact named artifact_name.

Parameters
  • log_level (str | int | LogLevel) โ€“ The log level, which can be a name, value, or instance of LogLevel.

  • artifact_name (str) โ€“ The name of the artifact.

  • file_path (str | Path) โ€“ The file path.

  • overwrite (bool, optional) โ€“ Whether to overwrite an existing artifact with the same artifact_name. (default: False)

Symlink existing_artifact_name as symlink_artifact_name.

Parameters
  • log_level (str | int | LogLevel) โ€“ The log level, which can be a name, value, or instance of LogLevel.

  • existing_artifact_name (str) โ€“ The name of symlinked artifact.

  • symlink_artifact_name (str) โ€“ The symlink name of artifact.

  • overwrite (bool, optional) โ€“ Whether to overwrite an existing artifact with the same symlink_artifact_name. (default: False)

composer.loggers.logger.format_log_data_value(data)[source]#

Recursively formats a given log data value into a string.

Parameters

data โ€“ Data to format.

Returns

str โ€“ data as a string.