Edit on GitHub

API Reference

This reference provides the details about the dvclive Python API module, which can be imported regularly, for example:

from dvclive import Live

If you use one of the supported ML Frameworks, you can jump directly to its corresponding page.

Basic Workflow

Initialize DVCLive

with Live(save_dvc_exp=True) as live:

See Live() for details.

Including save_dvc_exp=True will automatically track the results.

Log data

live.log_param("num_classes", 10)
params = {
    "num_classes": 10,
    "metrics": ["accuracy", "mae"],
    "optimizer": "adam"

See Live.log_param() / Live.log_params().

live.log_metric("acc", 0.9)

See Live.log_metric().

img = np.ones((500, 500, 3), np.uint8)
live.log_image("image.png", img)

See Live.log_image().

y_true = [0, 0, 1, 1]
y_pred = [0.2, 0.5, 0.3, 0.8]
live.log_sklearn_plot("roc", y_true, y_score)

See Live.log_sklearn_plot().

(Optionally) Update the step number


See Live.next_step().

Under the hood, Live.next_step() calls Live.make_summary() and Live.make_report().

If you want to decouple the step update from the rest of the calls, you can manually modify the Live.step property and call Live.make_summary() / Live.make_report().

Putting it all together

Joining the above snippets, you can include DVCLive in your training code:

# train.py

from dvclive import Live

with Live(save_dvc_exp=True) as live:

    live.log_param("epochs", NUM_EPOCHS)

    for epoch in range(NUM_EPOCHS):
        metrics = evaluate_model(...)

        for metric_name, value in metrics.items():
            live.log_metric(metric_name, value)



After you run your training code, all the logged data will be stored in the dvclive directory. Check the DVCLive outputs page for more details.


🐛 Found an issue? Let us know! Or fix it:

Edit on GitHub

Have a question? Join our chat, we will help you:

Discord Chat