MCPcopy
hub / github.com/tensorflow/tensorboard

github.com/tensorflow/tensorboard @2.21.0 sqlite

repository ↗ · DeepWiki ↗ · release 2.21.0 ↗
9,585 symbols 25,853 edges 1,305 files 2,192 documented · 23%
README

TensorBoard GitHub Actions CI GitHub Actions Nightly CI PyPI

TensorBoard is a suite of web applications for inspecting and understanding your TensorFlow runs and graphs.

This README gives an overview of key concepts in TensorBoard, as well as how to interpret the visualizations TensorBoard provides. For an in-depth example of using TensorBoard, see the tutorial: TensorBoard: Getting Started. Documentation on how to use TensorBoard to work with images, graphs, hyper parameters, and more are linked from there, along with tutorial walk-throughs in Colab.

TensorBoard is designed to run entirely offline, without requiring any access to the Internet. For instance, this may be on your local machine, behind a corporate firewall, or in a datacenter.

Usage

Before running TensorBoard, make sure you have generated summary data in a log directory by creating a summary writer:

# sess.graph contains the graph definition; that enables the Graph Visualizer.

file_writer = tf.summary.FileWriter('/path/to/logs', sess.graph)

For more details, see the TensorBoard tutorial. Once you have event files, run TensorBoard and provide the log directory. If you're using a precompiled TensorFlow package (e.g. you installed via pip), run:

tensorboard --logdir path/to/logs

Or, if you are building from source:

bazel build tensorboard:tensorboard
./bazel-bin/tensorboard/tensorboard --logdir path/to/logs

# or even more succinctly
bazel run tensorboard -- --logdir path/to/logs

This should print that TensorBoard has started. Next, connect to http://localhost:6006.

TensorBoard requires a logdir to read logs from. For info on configuring TensorBoard, run tensorboard --help.

TensorBoard can be used in Google Chrome or Firefox. Other browsers might work, but there may be bugs or performance issues.

Key Concepts

Summary Ops: How TensorBoard gets data from TensorFlow

The first step in using TensorBoard is acquiring data from your TensorFlow run. For this, you need summary ops. Summary ops are ops, just like tf.matmul and tf.nn.relu, which means they take in tensors, produce tensors, and are evaluated from within a TensorFlow graph. However, summary ops have a twist: the Tensors they produce contain serialized protobufs, which are written to disk and sent to TensorBoard. To visualize the summary data in TensorBoard, you should evaluate the summary op, retrieve the result, and then write that result to disk using a summary.FileWriter. A full explanation, with examples, is in the tutorial.

The supported summary ops include: * tf.summary.scalar * tf.summary.image * tf.summary.audio * tf.summary.text * tf.summary.histogram

Tags: Giving names to data

When you make a summary op, you will also give it a tag. The tag is basically a name for the data recorded by that op, and will be used to organize the data in the frontend. The scalar and histogram dashboards organize data by tag, and group the tags into folders according to a directory/like/hierarchy. If you have a lot of tags, we recommend grouping them with slashes.

Event Files & LogDirs: How TensorBoard loads the data

summary.FileWriters take summary data from TensorFlow, and then write them to a specified directory, known as the logdir. Specifically, the data is written to an append-only record dump that will have "tfevents" in the filename. TensorBoard reads data from a full directory, and organizes it into the history of a single TensorFlow execution.

Why does it read the whole directory, rather than an individual file? You might have been using supervisor.py to run your model, in which case if TensorFlow crashes, the supervisor will restart it from a checkpoint. When it restarts, it will start writing to a new events file, and TensorBoard will stitch the various event files together to produce a consistent history of what happened.

Runs: Comparing different executions of your model

You may want to visually compare multiple executions of your model; for example, suppose you've changed the hyperparameters and want to see if it's converging faster. TensorBoard enables this through different "runs". When TensorBoard is passed a logdir at startup, it recursively walks the directory tree rooted at logdir looking for subdirectories that contain tfevents data. Every time it encounters such a subdirectory, it loads it as a new run, and the frontend will organize the data accordingly.

For example, here is a well-organized TensorBoard log directory, with two runs, "run1" and "run2".

/some/path/mnist_experiments/
/some/path/mnist_experiments/run1/
/some/path/mnist_experiments/run1/events.out.tfevents.1456525581.name
/some/path/mnist_experiments/run1/events.out.tfevents.1456525585.name
/some/path/mnist_experiments/run2/
/some/path/mnist_experiments/run2/events.out.tfevents.1456525385.name
/tensorboard --logdir /some/path/mnist_experiments

Logdir & Logdir_spec (Legacy Mode)

You may also pass a comma separated list of log directories, and TensorBoard will watch each directory. You can also assign names to individual log directories by putting a colon between the name and the path, as in

tensorboard --logdir_spec name1:/path/to/logs/1,name2:/path/to/logs/2

This flag (--logdir_spec) is discouraged and can usually be avoided. TensorBoard walks log directories recursively; for finer-grained control, prefer using a symlink tree. Some features may not work when using --logdir_spec instead of --logdir.

The Visualizations

Scalar Dashboard

TensorBoard's Scalar Dashboard visualizes scalar statistics that vary over time; for example, you might want to track the model's loss or learning rate. As described in Key Concepts, you can compare multiple runs, and the data is organized by tag. The line charts have the following interactions:

  • Clicking on the small blue icon in the lower-left corner of each chart will expand the chart

  • Dragging a rectangular region on the chart will zoom in

  • Double clicking on the chart will zoom out

  • Mousing over the chart will produce crosshairs, with data values recorded in the run-selector on the left.

Additionally, you can create new folders to organize tags by writing regular expressions in the box in the top-left of the dashboard.

Histogram Dashboard

The Histogram Dashboard displays how the statistical distribution of a Tensor has varied over time. It visualizes data recorded via tf.summary.histogram. Each chart shows temporal "slices" of data, where each slice is a histogram of the tensor at a given step. It's organized with the oldest timestep in the back, and the most recent timestep in front. By changing the Histogram Mode from "offset" to "overlay", the perspective will rotate so that every histogram slice is rendered as a line and overlaid with one another.

Distribution Dashboard

The Distribution Dashboard is another way of visualizing histogram data from tf.summary.histogram. It shows some high-level statistics on a distribution. Each line on the chart represents a percentile in the distribution over the data: for example, the bottom line shows how the minimum value has changed over time, and the line in the middle shows how the median has changed. Reading from top to bottom, the lines have the following meaning: [maximum, 93%, 84%, 69%, 50%, 31%, 16%, 7%, minimum]

These percentiles can also be viewed as standard deviation boundaries on a normal distribution: [maximum, μ+1.5σ, μ+σ, μ+0.5σ, μ, μ-0.5σ, μ-σ, μ-1.5σ, minimum] so that the colored regions, read from inside to outside, have widths [σ, 2σ, 3σ] respectively.

Image Dashboard

The Image Dashboard can display pngs that were saved via a tf.summary.image. The dashboard is set up so that each row corresponds to a different tag, and each column corresponds to a run. Since the image dashboard supports arbitrary pngs, you can use this to embed custom visualizations (e.g. matplotlib scatterplots) into TensorBoard. This dashboard always shows you the latest image for each tag.

Audio Dashboard

The Audio Dashboard can embed playable audio widgets for audio saved via a tf.summary.audio. The dashboard is set up so that each row corresponds to a different tag, and each column corresponds to a run. This dashboard always embeds the latest audio for each tag.

Graph Explorer

The Graph Explorer can visualize a TensorBoard graph, enabling inspection of the TensorFlow model. To get best use of the graph visualizer, you should use name scopes to hierarchically group the ops in your graph - otherwise, the graph may be difficult to decipher. For more information, including examples, see the examining the TensorFlow graph tutorial.

Embedding Projector

The Embedding Projector allows you to visualize high-dimensional data; for example, you may view your input data after it has been embedded in a high- dimensional space by your model. The embedding projector reads data from your model checkpoint file, and may be configured with additional metadata, like a vocabulary file or sprite images. For more details, see the embedding projector tutorial.

Text Dashboard

The Text Dashboard displays text snippets saved via tf.summary.text. Markdown features including hyperlinks, lists, and tables are all supported.

Time Series Dashboard

The Time Series Dashboard shows a unified interface containing all your Scalars, Histograms, and Images saved via tf.summary.scalar, tf.summary.image, or tf.summary.histogram. It enables viewing your 'accuracy' line chart side by side with activation histograms and training example images, for example.

Features include:

  • Custom run colors: click on the colored circles in the run selector to change a run's color.

  • Pinned cards: click the 'pin' icon on any card to add it to the pinned section at the top for quick comparison.

  • Settings: the right pane offers settings for charts and other visualizations. Important settings will persist across TensorBoard sessions, when hosted at the same URL origin.

  • Autocomplete in tag filter: search for specific charts more easily.

Frequently Asked Questions

My TensorBoard isn't showing any data! What's wrong?

First, check that the directory passed to --logdir is correct. You can also verify this by navigating to the Scalars dashboard (under the "Inactive" menu) and looking for the log directory path at the bottom of the left sidebar.

If you're loading from the proper path, make sure that event files are present. TensorBoard will recursively walk its logdir, it's fine if the data is nested under a subdirectory. Ensure the following shows at least one result:

find DIRECTORY_PATH | grep tfevents

You can also check that the event files actually have data by running tensorboard in inspect mode to inspect the contents of your event files.

tensorboard --inspect --logdir DIRECTORY_PATH

The output for an event file corresponding to a blank TensorBoard may still sometimes show a few steps, representing a few initial events that aren't shown by TensorBoard (for example, when using the Keras TensorBoard callback):

tensor
   first_step           0
   last_step            2
   max_step             2
   min_step             0
   num_steps            2
   outoforder_steps     [(2, 0), (2, 0), (2, 0)]

In contrast, the output for an event file with more data might look like this:

tensor
   first_step           0
   last_step            55
   max_step             250
   min_step             0
   num_steps            60
   outoforder_steps     [(2, 0), (2, 0), (2, 0), (2, 0), (50, 9), (100, 19), (150, 29), (200, 39), (250, 49)]

TensorBoard is showing only some of my data, or isn't properly updating!

Update: After [2.3.0 release][2-3-0], TensorBoard no longer auto reloads every 30 seconds. To re-enable the behavior, please open the settings by clicking the gear icon in the top-right of the TensorBoard web interface, and enable "Reload data".

Update: the [experimental --reload_multifile=true option][pr-1867] can now be used to poll all "active" files in a directory for new data, rather than the most recent one as described below. A file is "active" as long as it received new data within --reload_multifile_inactive_secs seconds ago, defaulting to 86400.

This issue usually comes about because of how TensorBoard iterates through the tfevents files: it progresses through

Extension points exported contracts — how you extend this code

AxisBrushFilter (Interface)
* An AxisBrushFilter is essentially a function indicating whether a given * value in the domain of the axis is inside t [6 …
tensorboard/plugins/hparams/tf_hparams_parallel_coords_plot/axes.ts
VzHistogramTimeSeriesElement (Interface)
(no doc) [18 implementers]
tensorboard/webapp/tb_polymer_interop_types.ts
JSON (Interface)
(no doc) [3 implementers]
tensorboard/defs/strict_type_check.d.ts
TrustedResourceUrlProtoOrBuilder (Interface)
(no doc) [3 implementers]
third_party/safe_html_types/com/google/common/html/types/TrustedResourceUrlProtoOrBuilder.java
LineChartTooltipColumn (Interface)
* Adds private APIs for default swatch column on the first column.
tensorboard/components/vz_line_chart2/line-chart.ts
TfDistributionLoader (Interface)
(no doc) [26 implementers]
tensorboard/plugins/distribution/tf_distribution_dashboard/tf-distribution-loader.ts
Scale (Interface)
(no doc) [6 implementers]
tensorboard/webapp/widgets/line_chart_v2/lib/scale_types.ts
MapConstructor (Interface)
(no doc)
tensorboard/defs/strict_type_check.d.ts

Core symbols most depended-on inside this repo

query
called by 735
tensorboard/plugins/projector/vz_projector/data.ts
get
called by 723
tensorboard/webapp/webapp_data_source/tb_http_client_types.ts
join
called by 472
tensorboard/compat/tensorflow_stub/io/gfile.py
buildRun
called by 287
tensorboard/webapp/runs/store/testing.ts
next
called by 282
tensorboard/compat/tensorflow_stub/io/gfile.py
buildMetricsState
called by 267
tensorboard/webapp/metrics/testing.ts
set
called by 246
tensorboard/plugins/projector/projector_plugin.py
push
called by 240
tensorboard/plugins/projector/vz_projector/heap.ts

Shape

Method 5,755
Function 1,628
Class 1,617
Interface 485
Enum 91
Route 9

Languages

TypeScript54%
Python39%
Java7%

Modules by API surface

tensorboard/data/provider.py100 symbols
tensorboard/backend/application_test.py97 symbols
third_party/safe_html_types/com/google/common/html/types/SafeHtmlBuilder.java93 symbols
tensorboard/plugins/graph/tf_graph_common/graph.ts69 symbols
tensorboard/compat/tensorflow_stub/io/gfile.py67 symbols
tensorboard/plugins/hparams/list_session_groups_test.py65 symbols
tensorboard/compat/tensorflow_stub/tensor_shape.py63 symbols
tensorboard/plugins/graph/tf_graph_common/render.ts62 symbols
tensorboard/plugins/debugger_v2/debugger_v2_plugin_test.py56 symbols
tensorboard/plugins/hparams/summary_v2_test.py54 symbols
tensorboard/components/vz_line_chart2/line-chart.ts53 symbols
tensorboard/plugins/projector/vz_projector/scatterPlot.ts52 symbols

Dependencies from manifests, versioned

@angular-devkit/build-angular17.0.0 · 1×
@angular/animations17.0.0 · 1×
@angular/build-toolinghttps://github.com/a · 1×
@angular/cdk17.0.0 · 1×
@angular/cli17.0.0 · 1×
@angular/common17.3.12 · 1×
@angular/compiler17.3.12 · 1×
@angular/compiler-cli17.0.0 · 1×
@angular/core17.0.0 · 1×
@angular/forms17.0.0 · 1×
@angular/localize17.0.0 · 1×
@angular/material17.0.0 · 1×

For agents

$ claude mcp add tensorboard \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact