Skip to content
Edit on GitHub


DVCLive allows you to add experiment tracking capabilities to your TensorFlow projects.


To start using DVCLive you just need to add a few lines to your training code in any TensorFlow project.

💡 If you prefer the Keras API, check the DVCLive - Keras page.

You need to add Live.log() calls to each place where you would like to log metrics and one single Live.next_step() call to indicate that the epoch has ended.

let's consider the following example, extracted from the official TensorFlow guide:

+ from dvclive import Live

+ live = Live()

for epoch in range(epochs):
    start_time = time.time()
    for step, (x_batch_train, y_batch_train) in enumerate(train_dataset):
        with tf.GradientTape() as tape:
            logits = model(x_batch_train, training=True)
            loss_value = loss_fn(y_batch_train, logits)
        grads = tape.gradient(loss_value, model.trainable_weights)
        optimizer.apply_gradients(zip(grads, model.trainable_weights))
        train_acc_metric.update_state(y_batch_train, logits)

+    live.log("train/accuracy", float(train_acc_metric.result())

    for x_batch_val, y_batch_val in val_dataset:
        val_logits = model(x_batch_val, training=False)
        val_acc_metric.update_state(y_batch_val, val_logits)
+    live.log("val/accuracy", float(val_acc_metric.result())

+    live.next_step()

This will generate the outputs as described in the Get Started.

Without requiring additional modifications to your training code, you can use DVCLive alongside DVC. See DVCLive with DVC for more info.


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

Edit on GitHub

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

Discord Chat