Skip to main content

Experiments logger for ML projects.

Project description

DVCLive

PyPI Status Python Version License

Tests Codecov pre-commit Black

DVCLive is a Python library for logging machine learning metrics and other metadata in simple file formats, which is fully compatible with DVC.

Documentation


Quickstart

Python API Overview PyTorch Lightning Scikit-learn Ultralytics YOLO v8

Install dvclive

$ pip install dvclive

Initialize DVC Repository

$ git init
$ dvc init
$ git commit -m "DVC init"

Example code

Copy the snippet below into train.py for a basic API usage example:

import time
import random

from dvclive import Live

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

with Live() as live:

    # log a parameters
    for param in params:
        live.log_param(param, params[param])

    # simulate training
    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 to studio
        live.log_metric("accuracy", accuracy)
        live.log_metric("loss", loss)
        live.next_step()
        time.sleep(0.2)

See Integrations for examples using DVCLive alongside different ML Frameworks.

Running

Run this a couple of times to simulate multiple experiments:

$ python train.py
$ python train.py
$ python train.py
...

Comparing

DVCLive outputs can be rendered in different ways:

DVC CLI

You can use dvc exp show and dvc plots to compare and visualize metrics, parameters and plots across experiments:

$ dvc exp show
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Experiment                 Created    train.accuracy   train.loss   val.accuracy   val.loss   step   epochs
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
workspace                  -                  6.0109      0.23311          6.062    0.24321      6   7
master                     08:50 PM                -            -              -          -      -   -
├── 4475845 [aulic-chiv]   08:56 PM           6.0109      0.23311          6.062    0.24321      6   7
├── 7d4cef7 [yarer-tods]   08:56 PM           4.8551      0.82012         4.5555   0.033533      4   5
└── d503f8e [curst-chad]   08:56 PM           4.9768     0.070585         4.0773    0.46639      4   5
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
$ dvc plots diff $(dvc exp list --names-only) --open

dvc plots diff

DVC Extension for VS Code

Inside the DVC Extension for VS Code, you can compare and visualize results using the Experiments and Plots views:

VSCode Experiments

VSCode Plots

While experiments are running, live updates will be displayed in both views.

DVC Studio

If you push the results to DVC Studio, you can compare experiments against the entire repo history:

Studio Compare

You can enable Studio Live Experiments to see live updates while experiments are running.


Comparison to related technologies

DVCLive is an ML Logger, similar to:

The main differences with those ML Loggers are:

  • DVCLive does not require any additional services or servers to run.
  • DVCLive metrics, parameters, and plots are stored as plain text files that can be versioned by tools like Git or tracked as pointers to files in DVC storage.
  • DVCLive can save experiments or runs as hidden Git commits.

You can then use different options to visualize the metrics, parameters, and plots across experiments.


Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the Apache 2.0 license, dvclive is free and open source software.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dvclive-3.49.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dvclive-3.49.0-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file dvclive-3.49.0.tar.gz.

File metadata

  • Download URL: dvclive-3.49.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dvclive-3.49.0.tar.gz
Algorithm Hash digest
SHA256 e5316ffeeed2bab6ebc470d6e754954962d7252a88f97b206106a83841ba5291
MD5 d26bc257bf39b857e6513e642bccb398
BLAKE2b-256 f80325f5d023587fc981983525b22577ef620d6b52623571ef291261ee4de01c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dvclive-3.49.0.tar.gz:

Publisher: release.yml on iterative/dvclive

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dvclive-3.49.0-py3-none-any.whl.

File metadata

  • Download URL: dvclive-3.49.0-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dvclive-3.49.0-py3-none-any.whl
Algorithm Hash digest
SHA256 217ca54940098617ccecb280b1fe8d858711e957a65b04b384ffacaec252f90e
MD5 9690ccabcda97731fac0e7be8d2da02d
BLAKE2b-256 ffbbdf4bc4ae83acad94136043d695c406a38529657e611a28ed25a93ddfdefe

See more details on using hashes here.

Provenance

The following attestation bundles were made for dvclive-3.49.0-py3-none-any.whl:

Publisher: release.yml on iterative/dvclive

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page