Loggers

class BaseLogger[source]

Bases: ABC

Base class for all experiment loggers.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None)[source]

Initialize the logger.

Parameters:
  • experiment_name (str) – Name of the experiment

  • run_name (str | None) – Name of the run within the experiment

  • tracking_uri (str | None) – URI for the tracking server (e.g., MLflow server, W&B server)

  • artifact_location (str | None) – Location to store artifacts (e.g., S3 bucket, local path)

  • tags (Dict[str, str] | None) – Additional tags to attach to the experiment

abstract start_run()[source]

Start a new run.

Return type:

None

abstract end_run()[source]

End the current run.

Return type:

None

abstract log_params(params)[source]

Log parameters for the run.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

abstract log_metrics(metrics, step=None)[source]

Log metrics for the run.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

abstract log_model(model, artifact_path, metadata=None)[source]

Log a model artifact.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

abstract log_image(image, title, step=None)[source]

Log an image.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None

class MLFlowLogger[source]

Bases: BaseLogger

MLflow implementation of the experiment logger.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None)[source]

Initialize the MLflow logger.

Parameters:
  • experiment_name (str) – Name of the experiment

  • run_name (str | None) – Name of the run within the experiment

  • tracking_uri (str | None) – URI for the MLflow tracking server

  • artifact_location (str | None) – Location to store artifacts (e.g., S3 bucket)

  • tags (Dict[str, str] | None) – Additional tags to attach to the experiment

start_run()[source]

Start a new MLflow run.

end_run()[source]

End the current MLflow run.

Return type:

None

log_params(params)[source]

Log parameters using MLflow.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

log_metrics(metrics, step=None)[source]

Log metrics using MLflow.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

log_model(model, artifact_path, metadata=None)[source]

Log a PyTorch model using MLflow.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

log_image(image, title, step=None)[source]

Log an image using MLflow.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None

class TensorBoardLogger[source]

Bases: BaseLogger

TensorBoard implementation of the experiment logger.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None)[source]

Initialize the TensorBoard logger.

Parameters:
  • experiment_name (str) – Name of the experiment

  • run_name (str | None) – Name of the run within the experiment

  • tracking_uri (str | None) – Not used in TensorBoard

  • artifact_location (str | None) – Root directory for TensorBoard logs

  • tags (Dict[str, str] | None) – Additional tags (added as text in TensorBoard)

start_run()[source]

Start a new TensorBoard run by creating the writer.

Return type:

None

end_run()[source]

End the current TensorBoard run.

Return type:

None

log_params(params)[source]

Log parameters using TensorBoard.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

log_metrics(metrics, step=None)[source]

Log metrics using TensorBoard.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

log_model(model, artifact_path, metadata=None)[source]

Log a PyTorch model using TensorBoard.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

log_image(image, title, step=None)[source]

Log an image using TensorBoard.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None

class WandbLogger[source]

Bases: BaseLogger

Weights & Biases implementation of the experiment logger.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None, project=None, entity=None)[source]

Initialize the W&B logger.

Parameters:
  • experiment_name (str) – Name of the experiment (used as group in W&B)

  • run_name (str | None) – Name of the run

  • tracking_uri (str | None) – Not used in W&B

  • artifact_location (str | None) – Local directory for artifacts

  • tags (Dict[str, str] | None) – Additional tags for the run

  • project (str | None) – W&B project name (required)

  • entity (str | None) – W&B entity (username or team name)

start_run()[source]

Start a new W&B run.

Return type:

None

end_run()[source]

End the current W&B run.

Return type:

None

log_params(params)[source]

Log parameters using W&B.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

log_metrics(metrics, step=None)[source]

Log metrics using W&B.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

log_model(model, artifact_path, metadata=None)[source]

Log a PyTorch model using W&B.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

log_image(image, title, step=None)[source]

Log an image using W&B.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None

TensorBoard Logger

class TensorBoardLogger[source]

Bases: BaseLogger

TensorBoard implementation of the experiment logger.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None)[source]

Initialize the TensorBoard logger.

Parameters:
  • experiment_name (str) – Name of the experiment

  • run_name (str | None) – Name of the run within the experiment

  • tracking_uri (str | None) – Not used in TensorBoard

  • artifact_location (str | None) – Root directory for TensorBoard logs

  • tags (Dict[str, str] | None) – Additional tags (added as text in TensorBoard)

start_run()[source]

Start a new TensorBoard run by creating the writer.

Return type:

None

end_run()[source]

End the current TensorBoard run.

Return type:

None

log_params(params)[source]

Log parameters using TensorBoard.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

log_metrics(metrics, step=None)[source]

Log metrics using TensorBoard.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

log_model(model, artifact_path, metadata=None)[source]

Log a PyTorch model using TensorBoard.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

log_image(image, title, step=None)[source]

Log an image using TensorBoard.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None

MLflow Logger

class MLFlowLogger[source]

Bases: BaseLogger

MLflow implementation of the experiment logger.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None)[source]

Initialize the MLflow logger.

Parameters:
  • experiment_name (str) – Name of the experiment

  • run_name (str | None) – Name of the run within the experiment

  • tracking_uri (str | None) – URI for the MLflow tracking server

  • artifact_location (str | None) – Location to store artifacts (e.g., S3 bucket)

  • tags (Dict[str, str] | None) – Additional tags to attach to the experiment

start_run()[source]

Start a new MLflow run.

end_run()[source]

End the current MLflow run.

Return type:

None

log_params(params)[source]

Log parameters using MLflow.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

log_metrics(metrics, step=None)[source]

Log metrics using MLflow.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

log_model(model, artifact_path, metadata=None)[source]

Log a PyTorch model using MLflow.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

log_image(image, title, step=None)[source]

Log an image using MLflow.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None

Weights & Biases Logger

class WandbLogger[source]

Bases: BaseLogger

Weights & Biases implementation of the experiment logger.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None, project=None, entity=None)[source]

Initialize the W&B logger.

Parameters:
  • experiment_name (str) – Name of the experiment (used as group in W&B)

  • run_name (str | None) – Name of the run

  • tracking_uri (str | None) – Not used in W&B

  • artifact_location (str | None) – Local directory for artifacts

  • tags (Dict[str, str] | None) – Additional tags for the run

  • project (str | None) – W&B project name (required)

  • entity (str | None) – W&B entity (username or team name)

start_run()[source]

Start a new W&B run.

Return type:

None

end_run()[source]

End the current W&B run.

Return type:

None

log_params(params)[source]

Log parameters using W&B.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

log_metrics(metrics, step=None)[source]

Log metrics using W&B.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

log_model(model, artifact_path, metadata=None)[source]

Log a PyTorch model using W&B.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

log_image(image, title, step=None)[source]

Log an image using W&B.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None

Base Logger

class BaseLogger[source]

Bases: ABC

Base class for all experiment loggers.

__init__(experiment_name, run_name=None, tracking_uri=None, artifact_location=None, tags=None)[source]

Initialize the logger.

Parameters:
  • experiment_name (str) – Name of the experiment

  • run_name (str | None) – Name of the run within the experiment

  • tracking_uri (str | None) – URI for the tracking server (e.g., MLflow server, W&B server)

  • artifact_location (str | None) – Location to store artifacts (e.g., S3 bucket, local path)

  • tags (Dict[str, str] | None) – Additional tags to attach to the experiment

abstract start_run()[source]

Start a new run.

Return type:

None

abstract end_run()[source]

End the current run.

Return type:

None

abstract log_params(params)[source]

Log parameters for the run.

Parameters:

params (Dict[str, Any]) – Dictionary of parameters to log

Return type:

None

abstract log_metrics(metrics, step=None)[source]

Log metrics for the run.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metrics to log

  • step (int | None) – Current step/epoch number

Return type:

None

abstract log_model(model, artifact_path, metadata=None)[source]

Log a model artifact.

Parameters:
  • model (Module) – PyTorch model to log

  • artifact_path (str) – Path where to save the model

  • metadata (Dict[str, Any] | None) – Additional metadata to log with the model

Return type:

None

abstract log_image(image, title, step=None)[source]

Log an image.

Parameters:
  • image (Tensor | Path | str) – Image to log (can be a tensor, file path, or URL)

  • title (str) – Title/tag for the image

  • step (int | None) – Current step/epoch number

Return type:

None