TensorBoard Nightly
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
- breaking TensorBoard.dev, the hosted service for sharing TensorBoard experiments, has been shut down as of January 1, 2024. The `tensorboard dev upload` command will no longer function.
- gotcha Installing both `tensorboard` and `tb-nightly` packages in the same environment can lead to file overwrites and hard-to-debug errors, as they both ship the `tensorboard` Python package.
- breaking Python 3.13 removed the built-in `imghdr` module, causing `ModuleNotFoundError` for older TensorBoard versions attempting to import it.
- gotcha TensorBoard has historically faced compatibility issues with `protobuf` versions, leading to runtime errors. Conflicts can arise if other installed libraries pin `protobuf` to an incompatible version.
- gotcha Compatibility issues can arise with `numpy` 2.0. TensorBoard has released updates to ensure compatibility with changes in `numpy` 2.0. [cite: 2.18.0, 2.17.1 release notes]
Install
-
pip install tb-nightly
Imports
- SummaryWriter
from torch.utils.tensorboard import SummaryWriter
- TensorBoard (Keras Callback)
from tensorflow.keras.callbacks import TensorBoard
- tf.summary
import tensorflow as tf; tf.summary
- Program
from tensorboard import program
Quickstart
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/")