Edit on GitHub

TensorFlow

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

About TensorFlow

TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries, and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML-powered applications.

Usage

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.

To ilustrate with some code, 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())
    train_acc_metric.reset_states()

    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())
    val_acc_metric.reset_states()

+    live.next_step()

This will generate the metrics logs and summaries 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.

Content

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

Edit on GitHub

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

Discord Chat