---
title: Track and Visualize Experiments
description: >-
  In model development, we track values of interest, such as the validationloss
  to visualize the learning process for our models.
canonical: 'https://lightning.ai/docs/fabric/stable/reference/guide/logging'
---
# Track and Visualize Experiments {#track-and-visualize-experiments}

## Why do I need to track metrics? {#why-do-i-need-to-track-metrics}

In model development, we track values of interest, such as the *validation_loss* to visualize the learning process for our models.
Model development is like driving a car without windows. Charts and logs provide the *windows* to know where to drive the car.

With Lightning, you can visualize virtually anything you can think of: numbers, text, images, and audio.

## Track metrics {#track-metrics}

Metric visualization is the most basic but powerful way to understand how your model is doing throughout development.
To track a metric, add the following:

**Step 1:** Pick a logger.

```python
from lightning.fabric import Fabric
from lightning.fabric.loggers import TensorBoardLogger

# Pick a logger and add it to Fabric
logger = TensorBoardLogger(root_dir="logs")
fabric = Fabric(loggers=logger)
```

Loggers you can choose from:

- `TensorBoardLogger`
- `CSVLogger`
- [LitLogger](/docs/fabric/2.6.6/reference/guide/loggers/litlogger.md)
- [WandbLogger](/docs/fabric/2.6.6/reference/guide/loggers/wandb.md)

**Step 2:** Add `log` calls in your code.

```python
value = ...  # Python scalar or tensor scalar
fabric.log("some_value", value)
```

To log multiple metrics at once, use `log_dict`:

```python
values = {"loss": loss, "acc": acc, "other": other}
fabric.log_dict(values)
```

## View logs dashboard {#view-logs-dashboard}

How you can view the metrics depends on the individual logger you choose.
Most have a dashboard that lets you browse everything you log in real time.

For the `TensorBoardLogger` shown above, you can open it by running

```bash
tensorboard --logdir=./logs
```

If you're using a notebook environment such as *Google Colab* or *Kaggle* or *Jupyter*, launch TensorBoard with this command

```bash
%reload_ext tensorboard
%tensorboard --logdir=./logs
```

## Control logging frequency {#control-logging-frequency}

Logging a metric in every iteration can slow down the training.
Reduce the added overhead by logging less frequently:

```python
for iteration in range(num_iterations):
    if iteration % log_every_n_steps == 0:
        value = ...
        fabric.log("some_value", value)
```

## Use multiple loggers {#use-multiple-loggers}

You can add as many loggers as you want without changing the logging code in your loop.

```python
from lightning.fabric import Fabric
from lightning.fabric.loggers import CSVLogger, TensorBoardLogger

tb_logger = TensorBoardLogger(root_dir="logs/tensorboard")
csv_logger = CSVLogger(root_dir="logs/csv")

# Add multiple loggers in a list
fabric = Fabric(loggers=[tb_logger, csv_logger])

# Calling .log() or .log_dict() always logs to all loggers simultaneously
fabric.log("some_value", value)
```

---

**Navigation**

- Parent: [Guide](/docs/fabric/2.6.6/reference/guide.md)
