Edit on GitHub
Live.log_metric()
def log_metric(
name: str,
val: Union[int, float, str],
timestamp: bool = False,
plot: Optional[bool] = True
):Usage
from dvclive import Live
with Live() as live:
live.log_metric("train/loss", 0.4)
live.log_metric("val/loss", 0.9)Description
On each Live.log_metric(name, val) call DVCLive will create a metrics
history file in {Live.plots_dir}/metrics/{name}.tsv:
dvclive
├── metrics.json
└── plots
└── metrics
├── train
│ └── loss.tsv
└── val
└── loss.tsv$ cat dvclive/plots/metrics/train/loss.tsv
timestamp step loss
1623671484747 0 0.4The metrics history can be visualized with dvc plots:
$ dvc plots diff dvclive/plotsEach subsequent call to Live.log_metric(name, val) will add a new row to
{Live.plots_dir}/metrics/{name}.tsv:
live.next_step()
live.log_metric("train/loss", 0.2, timestamp=True)
live.log_metric("val/loss", 0.4, timestamp=True)timestamp step loss
1623671484747 0 0.4
1623671484892 1 0.2In addition, DVCLive will store the latest value logged in Live.summary, so it
can be serialized with calls to Live.make_summary(), Live.next_step() or
when exiting the with block:
{
"step": 1,
"train": {
"loss": 0.2
},
"val": {
"loss": 0.4
}
}