dvclive3.48.1
Published
Experiments logger for ML projects.
pip install dvclive
Package Downloads
Authors
Project URLs
Requires Python
>=3.9
Dependencies
- dvc
>=3.48.4
- dvc-render
<2,>=1.0.0
- dvc-studio-client
<1,>=0.20
- funcy
- gto
- ruamel.yaml
- scmrepo
<4,>=3
- psutil
- pynvml
- numpy
; extra == "image"
- pillow
; extra == "image"
- scikit-learn
; extra == "sklearn"
- scikit-learn
; extra == "plots"
- pandas
; extra == "plots"
- numpy
; extra == "plots"
- matplotlib
; extra == "markdown"
- pytest
<9.0,>=7.2.0; extra == "tests"
- pytest-sugar
<2.0,>=0.9.6; extra == "tests"
- pytest-cov
<6.0,>=3.0.0; extra == "tests"
- pytest-mock
<4.0,>=3.8.2; extra == "tests"
- dvclive
[image,markdown,plots]; extra == "tests"
- ipython
; extra == "tests"
- pytest_voluptuous
; extra == "tests"
- dpath
; extra == "tests"
- transformers
[torch]; extra == "tests"
- tf-keras
; extra == "tests"
- dvclive
[all,tests]; extra == "dev"
- mypy
==1.13.0; extra == "dev"
- types-PyYAML
; extra == "dev"
- mmcv
; extra == "mmcv"
- tensorflow
; extra == "tf"
- xgboost
; extra == "xgb"
- lightgbm
; extra == "lgbm"
- transformers
; extra == "huggingface"
- datasets
; extra == "huggingface"
- fastai
; extra == "fastai"
- lightning
>=2.0; extra == "lightning"
- torch
; extra == "lightning"
- jsonargparse
[signatures]>=4.26.1; extra == "lightning"
- optuna
; extra == "optuna"
- dvclive
[fastai,huggingface,image,lgbm,lightning,markdown,mmcv,optuna,plots,tf,xgb]; extra == "all"
DVCLive
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 Extension for VS Code
Inside the DVC Extension for VS Code, you can compare and visualize results using the Experiments and Plots views:
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:
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.