DVCLive

3.49.0 · active · verified Sat Apr 11

DVCLive is a Python library for logging machine learning metrics and other metadata. It is designed to be fully compatible with DVC (Data Version Control) and stores logged information in simple, human-readable file formats (like .tsv, .json, .yaml) that can be versioned by Git. It provides real-time experiment tracking and integrates with various ML frameworks, helping users maintain reproducible ML workflows. The current version is 3.49.0, and the library is actively developed with frequent releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic logging of parameters and metrics using `dvclive.Live` within a simulated training loop. Metrics and parameters will be saved in the `dvclive` directory, typically as `metrics.json`, `params.yaml`, and time-series `.tsv` files. Running this code multiple times will generate new experiment steps that can be tracked and compared with DVC.

import time
import random
from dvclive import Live

params = {"learning_rate": 0.002, "optimizer": "Adam", "epochs": 20}

with Live() as live:
    # Log parameters
    for param in params:
        live.log_param(param, params[param])

    # Simulate training loop
    offset = random.uniform(0.2, 0.1)
    for epoch in range(1, params["epochs"]):
        fuzz = random.uniform(0.01, 0.1)
        accuracy = 1 - (2 ** -epoch) - fuzz - offset
        loss = (2 ** -epoch) + fuzz + offset

        # Log metrics for the current step
        live.log_metric("accuracy", accuracy)
        live.log_metric("loss", loss)
        live.next_step()
        time.sleep(0.05) # Simulate work, shorten for quick demo

view raw JSON →