ml.loggers.base
Defines the base logger.
New loggers should implement whichever log_ functions they need to. Unimplemented functions are simply ignored. The framework will handle logging rate limiting and munging the logged values to a common format.
The internal ergonomics for logging are a bit confusing to follow. Each
component has access to a MultiLogger
which it can use to log values.
After each step, each MultiLogger
sends its values to any implemented
loggers which have should_write
return True
. This lets the implemented
loggers aggregate values over multiple ``MultiLogger``s. New loggers should
follow the implementation of one of the existing loggers.
- class ml.loggers.base.BaseLoggerConfig(name: str = '???', write_every_n_seconds: float | None = None, write_train_every_n_seconds: float | None = None, write_val_every_n_seconds: float | None = None)[source]
Bases:
BaseConfig
- write_every_n_seconds: float | None = None
- write_train_every_n_seconds: float | None = None
- write_val_every_n_seconds: float | None = None
- class ml.loggers.base.BaseLogger(config: LoggerConfigT)[source]
Bases:
BaseObject
[LoggerConfigT
],Generic
[LoggerConfigT
],ABC
Defines the base logger.
- log_directory: Path
- log_scalar(key: str, value: Callable[[], int | float | Tensor], state: State, namespace: str) None [source]
Logs a scalar value.
- Parameters:
key – The key to log
value – The value to log
state – The current log state
namespace – The namespace to be logged
- log_string(key: str, value: Callable[[], str], state: State, namespace: str) None [source]
Logs a string value.
- Parameters:
key – The key to log
value – The value to log
state – The current log state
namespace – The namespace to be logged
- log_image(key: str, value: Callable[[], Tensor], state: State, namespace: str) None [source]
Logs a normalized image, with shape (C, H, W).
- Parameters:
key – The key to log
value – The value to log
state – The current log state
namespace – The namespace to be logged
- log_audio(key: str, value: Callable[[], tuple[torch.Tensor, int]], state: State, namespace: str) None [source]
Logs a normalized audio, with shape (T,).
- Parameters:
key – The key to log
value – The value to log
state – The current log state
namespace – The namespace to be logged
- log_video(key: str, value: Callable[[], Tensor], state: State, namespace: str) None [source]
Logs a normalized video, with shape (T, C, H, W).
- Parameters:
key – The key to log
value – The value to log
state – The current log state
namespace – The namespace to be logged
- log_histogram(key: str, value: Callable[[], Tensor], state: State, namespace: str) None [source]
Logs a histogram, with any shape.
- Parameters:
key – The key to log
value – The value to log
state – The current log state
namespace – The namespace to be logged
- log_point_cloud(key: str, value: Callable[[], Tensor], state: State, namespace: str) None [source]
Logs a normalized point cloud, with shape (B, N, 3).
- Parameters:
key – The key to log
value – The value to log
state – The current log state
namespace – The namespace to be logged
- log_config(config: DictConfig) None [source]
Logs a set of metrics and configuration.
This is only called once, when metrics are computed for a whole dataset.
- Parameters:
config – The run config
- should_write(state: State) bool [source]
Returns whether or not the current state should be written.
This function checks that the last time the current phase was written was greater than some interval in the past, to avoid writing tons of values when the iteration time is extremely small.
- Parameters:
state – The state to check
- Returns:
If the logger should write values for the current state
- abstract write(state: State) None [source]
Writes the logs.
- Parameters:
state – The current log state