Install & Compatibility
Where this runs
tested against v1.8.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 22MB
19MB installed
● package 19MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
What-If Tool Plugin
✓ The plugin is primarily accessed via the TensorBoard UI after launching TensorBoard. There is no direct Python import for the main plugin functionality, though parts of the underlying 'witwidget' library might be imported for advanced programmatic use.
✗ from tensorboard_plugin_wit import WhatIfToolPlugin
The 'tensorboard-plugin-wit' package registers the What-If Tool as a TensorBoard plugin. Users interact with it through the TensorBoard web interface after launching TensorBoard. Direct programmatic control over the UI from Python is not the standard usage pattern.
This quickstart demonstrates how to generate basic TensorBoard logs. After running this Python code, launch TensorBoard from your terminal, pointing it to the parent directory of your logs. Once TensorBoard is running, navigate to its web interface (usually http://localhost:6006) and select the 'What-If Tool' from the dashboard dropdown. Note that for the What-If Tool to be fully functional, you would typically need a model served via TensorFlow Serving and a dataset in TFRecord format. This example primarily shows how to set up a basic TensorBoard environment where the plugin can be accessed.
import tensorflow as tf
import numpy as np
import os
from datetime import datetime
log_dir = os.path.join("logs", "whatif_example_" + datetime.now().strftime("%Y%m%d-%H%M%S"))
file_writer = tf.summary.create_file_writer(log_dir)
# Create some dummy data to log to TensorBoard
with file_writer.as_default():
tf.summary.scalar('my_metric/loss', 0.5, step=0)
tf.summary.scalar('my_metric/accuracy', 0.8, step=0)
tf.summary.text('my_experiment/details', 'This is a test run for What-If Tool integration.', step=0)
# What-If Tool also requires a TFRecord file with examples and a served model
# This example only shows basic TensorBoard logging to demonstrate a runnable context.
# For full WIT functionality, prepare TFRecord data and serve a model with TensorFlow Serving.
print(f"TensorBoard logs written to: {log_dir}")
print("To launch TensorBoard, run in your terminal:")
print(f"tensorboard --logdir {os.path.dirname(log_dir)}")
print("Then navigate to http://localhost:6006 and look for the What-If Tool dashboard.")
Debug
Known issues
deprecatedThe What-If Tool and its TensorBoard plugin are no longer actively maintained. Users are strongly encouraged to consider the actively maintained Learning Interpretability Tool (LIT) as an alternative for model understanding and interpretability.fixMigrate to the Learning Interpretability Tool (LIT) for ongoing support and new features.
affects: All versions, as of TensorFlow 2.11 and earlier documentation.
gotchaFull functionality of the What-If Tool in TensorBoard requires a model served via TensorFlow Serving. The model must expose its prediction interface through TensorFlow Serving's classify, regress, or predict API.fixEnsure your machine learning model is deployed using TensorFlow Serving before attempting to analyze it with the What-If Tool in TensorBoard. Alternatively, use 'notebook mode' or a custom Python prediction function provided to TensorBoard with `--whatif-use-unsafe-custom-prediction`.
affects: All versions.
gotchaInput datasets for analysis within the What-If Tool in TensorBoard must be in TFRecord file format containing TensorFlow 'Example' protocol buffers.fixConvert your dataset into the TFRecord format with TensorFlow Example protos. The TFRecord file needs to be accessible by the TensorBoard web server, typically under the `--logdir` or a path specified by `--whatif-data-dir`.
affects: All versions.
breakingMixing TensorFlow 1.x and 2.x environments or incompatible TensorBoard versions can lead to issues such as 'duplicate plugins' or 'ImportError: TensorBoard logging requires TensorBoard version 1.15 or above'. TensorBoard versions 2.4.0 and above explicitly require TensorFlow 2.x.fixEnsure consistent versions of TensorFlow and TensorBoard. If using TF 2.x, ensure TensorBoard is also 2.x compatible (preferably the latest compatible version). Consider using isolated virtual environments (e.g., `venv` or `conda`) to manage dependencies.
affects: TensorBoard 2.4.0+ and any older incompatible TensorFlow/TensorBoard setups.
Upgrade
Version history
1.8.1latest on PyPI · released Jan 5, 2022
Audit
Dependencies
tensorboardrequiredThe plugin integrates with and requires a TensorBoard installation to function. 'tensorboard-plugin-wit' is often installed automatically as a dependency of 'tensorboard'.
tensorflow-servingrequiredTo analyze a model within TensorBoard using WIT, the model must be served via TensorFlow Serving's classify, regress, or predict API.
tensorflowrequiredOften required for preparing data (e.g., TFRecord files) or for custom Python prediction functions if not using TensorFlow Serving. TensorBoard itself generally aligns with TensorFlow versions.