TensorBoard Nightly

2.21.0a20251023 · active · verified Sun Apr 12

tb-nightly is the nightly build for TensorBoard, a suite of web applications that provides visualization and tooling for machine learning experimentation. It allows users to track and visualize metrics like loss and accuracy, view model graphs, project embeddings, and display various data types. This version tracks the latest development of TensorFlow, offering bleeding-edge features and bug fixes. It follows an active release cadence, typically updating daily with the latest changes from the main development branch.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to train a simple Keras model and log its metrics and histograms to TensorBoard using the TensorBoard callback. After the script runs, it prints a command to launch the TensorBoard web interface to visualize the training process.

import datetime
import os

import tensorflow as tf

# Create a simple Keras model.
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

def create_model():
    return tf.keras.models.Sequential([
        tf.keras.layers.Flatten(input_shape=(28, 28)),
        tf.keras.layers.Dense(512, activation='relu'),
        tf.keras.layers.Dropout(0.2),
        tf.keras.layers.Dense(10, activation='softmax')
    ])

model = create_model()
model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

# Define the log directory
log_dir = os.path.join("logs", "fit", datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))

# Create a TensorBoard callback
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)

# Train the model while logging to TensorBoard
model.fit(x=x_train, y=y_train, epochs=5, validation_data=(x_test, y_test), callbacks=[tensorboard_callback])

print(f"TensorBoard logs saved to: {log_dir}")
print("To launch TensorBoard, run: tensorboard --logdir logs/")

view raw JSON →