composer.core.logging.logger#

Base classes, functions, and variables for logger.

composer.core.logging.logger.TLogDataValue#

Data value(s) to be logged. Can be any of the following types: str; float; int; torch.Tensor; Sequence[TLogDataValue]; Mapping[str, TLogDataValue].

composer.core.logging.logger.TLogData#

Name-value pair for data to be logged. Type Mapping[str, TLogDataValue]. Example: {"accuracy", 21.3}.

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

Logger routes metrics to the LoggerCallback.

Attributes

class composer.core.logging.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.

FIT#

Logged once per training run.

EPOCH#

Logged once per epoch.

BATCH#

Logged once per batch.

class composer.core.logging.logger.Logger(state, backends=())[source]#

Logger routes metrics to the LoggerCallback. Logger is what users call from within algorithms/callbacks. A logger routes the calls/data to any different number of destination LoggerCallbacks (e.g., FileLogger, InMemoryLogger, etc.). Data to be logged should be of the type TLogData (i.e., a {<name>: <value>} mapping).

Parameters
backends#

A sequence of LoggerCallbacks to which logging calls will be sent.

Type

Sequence[LoggerCallback]

metric(log_level, data)[source]#

Log a metric to the backends.

Parameters
  • log_level (Union[str, LogLevel]) โ€“ A LogLevel.

  • data (Union[TLogData, Callable[[], TLogData]]) โ€“ Can be either logging data or a callable that returns data to be logged. Callables will be invoked only when will_log() returns True for at least one LoggerCallback. Useful when it is expensive to generate the data to be logged.

metric_batch(data)[source]#

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

metric_epoch(data)[source]#

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

metric_fit(data)[source]#

Helper function for metric(LogLevel.FIT, data)

composer.core.logging.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.