HuggingFace TensorBoard Logger — push TensorBoard logs to the Hub.
Allows you to track experiment metrics and push TensorBoard logs to a HuggingFace repository, making them viewable in the Hub's embedded TensorBoard.
See: https://huggingface.co/docs/huggingface_hub/package_reference/tensorboard
Example
# Create a logger
logger = HuggingfaceClient.TensorBoard.new("my-org/my-model",
logdir: "./runs/exp1",
access_token: "hf_..."
)
# Log scalars (call during training)
HuggingfaceClient.TensorBoard.log_scalar(logger, "train/loss", 0.245, step: 100)
HuggingfaceClient.TensorBoard.log_scalar(logger, "eval/accuracy", 0.923, step: 100)
# Push logs to Hub
{:ok, url} = HuggingfaceClient.TensorBoard.push(logger)
IO.puts("TensorBoard available at: #{url}")
Summary
Functions
Logs a scalar metric value. Writes to local logdir.
Creates a new TensorBoard logger connected to a Hub repository.
Pushes all TensorBoard log files from logdir to the Hub repository.
Reads logged scalars from the local logdir.
Uploads TensorBoard log files from the logdir to the Hub.
Types
Functions
Logs a scalar metric value. Writes to local logdir.
In production, combine with a real TensorBoard library (e.g. :tensorflow).
This creates a simple JSON log as a fallback.
Example
HuggingfaceClient.TensorBoard.log_scalar(logger, "train/loss", 0.245, step: 100)
HuggingfaceClient.TensorBoard.log_scalar(logger, "eval/f1", 0.89, step: 100)
Creates a new TensorBoard logger connected to a Hub repository.
Options
:logdir— local directory for TensorBoard logs (default:"./runs"):access_token— HF API token:repo_type—:model|:dataset|:space(default::model):path_in_repo— directory in the repo (default:"runs"):private— create repo as private if it doesn't exist (default:false)
Example
logger = HuggingfaceClient.TensorBoard.new("my-org/my-training-run",
logdir: "./tb_logs",
access_token: token
)
@spec push( t(), keyword() ) :: {:ok, String.t()} | {:error, Exception.t()}
Pushes all TensorBoard log files from logdir to the Hub repository.
Creates the repository if it doesn't exist.
Example
{:ok, url} = HuggingfaceClient.TensorBoard.push(logger,
commit_message: "Epoch 10 training logs"
)
IO.puts("View at: #{url}")
Reads logged scalars from the local logdir.
Example
scalars = HuggingfaceClient.TensorBoard.read_scalars(logger)
loss_values = Enum.filter(scalars, fn s -> s["tag"] == "train/loss" end)
@spec upload_logs(t(), String.t()) :: {:ok, String.t()} | {:error, Exception.t()}
Uploads TensorBoard log files from the logdir to the Hub.
Example
{:ok, url} = HuggingfaceClient.TensorBoard.upload_logs(logger)