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.
- FIT
Logged once per training run.
- EPOCH
Logged once per epoch.
- BATCH
Logged once per batch.
- MICROBATCH
Logged once per microbatch (e.g. forward pass).
- VERBOSE
Logged for debugging.
- class composer.core.logging.logger.Logger(state: State, backends: Sequence[BaseLoggerBackend] = ())[source]
Logger routes metrics to the
BaseLoggerBackend
.- Parameters
backends (Sequence[BaseLoggerBackend]) – A sequence of
BaseLoggerBackend
s to which logging calls will be sent.
- backends
A sequence of
BaseLoggerBackend
s to which logging calls will be sent.- Type
Sequence[BaseLoggerBackend]
- metric(log_level: Union[str, composer.core.logging.logger.LogLevel], 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]]]]]) None [source]
Log a metric to the
backends
.- Parameters
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 oneBaseLoggerBackend
. Useful when it is expensive to generate the data to be logged.
- metric_batch(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]]]]]) None [source]
Helper function for
self.metric(LogLevel.BATCH, data)
- metric_epoch(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]]]]]) None [source]
Helper function for
self.metric(LogLevel.EPOCH, data)
- metric_fit(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]]]]]) None [source]
Helper function for
metric(LogLevel.FIT, data)
- metric_microbatch(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]]]]]) None [source]
Helper function for
self.metric(LogLevel.MICROBATCH, data)
- metric_verbose(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]]]]]) None [source]
Helper function for
self.metric(LogLevel.VERBOSE, data)