Logger and LogLevel

class composer.core.logging.logger.LogLevel(value)[source]

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

Logging destinations use the LogLevel to determine whether to record a given metric or state change

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

Logger records metrics and state changes to logging destinations.

It routes logging calls to the :class:`~compose.core.logging.base_backend.BaseLoggerBackend`s (specified in :param log_destinations:)

Parameters
  • state (State) – The global State object.

  • log_destinations (Sequence[BaseLoggerBackend]) – A sequence of :class:`~compose.core.logging.base_backend.BaseLoggerBackend`s to which logging calls will be sent.

metric(log_level, data)[source]

Send :param data: with :param log_level: to the logging 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 BaseLoggerBackend. Useful when it is expensive to generate the data to be logged.

Return type

None

metric_batch(data)[source]

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

Parameters

data (Union[Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]], Callable[[], Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]]]]) –

Return type

None

metric_epoch(data)[source]

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

Parameters

data (Union[Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]], Callable[[], Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]]]]) –

Return type

None

metric_fit(data)[source]

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

Parameters

data (Union[Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]], Callable[[], Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]]]]) –

Return type

None

metric_microbatch(data)[source]

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

Parameters

data (Union[Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]], Callable[[], Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]]]]) –

Return type

None

metric_verbose(data)[source]

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

Parameters

data (Union[Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]], Callable[[], Mapping[str, Union[str, float, int, torch.Tensor, Sequence[TLogDataValue], Mapping[str, TLogDataValue]]]]]) –

Return type

None