Creating a Logger¶
melissa.server.deep_learning.metric_logger.make_metric_logger(framework_t=None, rank=0, logdir='tensorboard', disable=False, debug=False, for_breed=False, logger_type=LoggerType.TENSORBOARD, config=None, wandb_project=None, wandb_prefix=None, wandb_group=None, **_unused_kwargs)
¶
Factory function to create a logger based on the specified type and deep learning framework.
Parameters¶
- rank (
int, optional): Rank of the process (used for distributed training). Defaults to0. - logdir (
str, optional): Directory where logs are stored. Defaults to"tensorboard". - disable (
bool, optional): IfTrue, disables logging. Defaults toFalse. - debug (
bool, optional): IfTrue, enables debug mode for the logger. Defaults toFalse. - for_breed (
bool, optional): IfTrue, creates a new summary writer dedicated forbreed_rank.- logger_type (
LoggerType, optional): Type of logger to create. EitherTENSORBOARDorWANDB. Defaults toTENSORBOARD. - wandb_project (
str, optional): Weights & Biases project name. - wandb_mode (
str, optional): W&B mode, e.g. "offline" or "online" (defaults to offline). - wandb_dir (
str, optional): Directory for wandb files (defaults to logdir). - wandb_group (
str, optional): Explicit W&B group name override. Defaults to a path-derived name if unset.
- logger_type (
Returns¶
BaseLogger: An instance of the appropriate logger (TensorboardLoggerorWandbLogger).
Raises¶
ModuleNotFoundError: IfWANDBis selected butwandbis not installed.
Logger Classes¶
melissa.server.deep_learning.metric_logger.base_logger.BaseLogger¶
Bases: ABC
Abstract base class for experiment loggers.
This class defines the interface that all logging backends must implement. Subclasses include TensorBoard logger and can be extended to cloud-based logger (Weights & Biases).
Parameters¶
- disable (
bool): If True, logging operations become no-ops. - debug (
bool): If True, enables debug-level logging.
Attributes¶
- disable (
bool): Whether logging is disabled. - debug (
bool): Whether debug mode is enabled. - _writer (
Any): The underlying writer object (backend-specific).
writer
property
¶
Returns the underlying writer object.
log_scalar(tag, scalar_value, step)
abstractmethod
¶
Logs a scalar value.
Parameters¶
- tag (
str): Metric tag/name. - scalar_value (
Any): Value to log. - step (
int): Step number.
log_scalars(main_tag, tag_scalar_dict, step)
¶
Logs multiple scalars under a common parent tag.
Parameters¶
- main_tag (
str): The parent name for the tags. - tag_scalar_dict (
dict): Key-value pairs of tag names and values. - step (
int): Step number.
log_scalar_dbg(tag, scalar_value, step)
abstractmethod
¶
Logs a debug-level scalar (only logged when debug mode is enabled).
Parameters¶
- tag (
str): Metric tag. - scalar_value (
Any): Value to log. - step (
int): Step number.
log_histogram(tag, values, step=None)
¶
Logs a histogram of values.
Parameters¶
- tag (
str): Metric tag. - values (
Any): Values to create histogram from. - step (
Optional[int]): Step number.
log_figure(tag, figure, step=None, close=True)
¶
Logs a matplotlib figure as an image.
Parameters¶
- tag (
str): Figure identifier. - figure (
Union[Figure, List[Figure]]): Figure or list of figures. - step (
Optional[int]): Step number. - close (
bool): Whether to close the figure after logging.
watch_model(model, **kwargs)
¶
Hook for loggers that support model/gradient watching (e.g., W&B).
Parameters¶
- model (
Any): The model to watch. - kwargs: Additional arguments for the specific logger.
close()
abstractmethod
¶
Flushes pending data and closes the logger.
Implementations should ensure all buffered data is written before closing.
melissa.server.deep_learning.metric_logger.tensorboard_logger.TensorboardLogger¶
Bases: BaseLogger
TensorBoard logger implementation using tensorboardX (no PyTorch/TensorFlow dependency).
log_histogram(tag, values, step=None)
¶
Log a histogram. Accepts any array-like (list, np.ndarray, etc.).
melissa.server.deep_learning.metric_logger.wandb_logger.WandbLogger¶
Bases: BaseLogger
Weights & Biases-backed logger implementing the BaseLogger interface.
- Defaults to offline mode (no network).
- Reuses a single run across processes via a persisted run-id file and wandb.run.
- Adapts TB-style API to wandb.log.