TensorBoard is a visualization tool provided with TensorFlow.
This callback logs events for TensorBoard, including:
Metrics summary plots
Training graph visualization
Weight histograms
Sampled profiling
When used in Model.evaluate, in addition to epoch summaries, there will be
a summary that records evaluation metrics vs Model.optimizer.iterations
written. The metric names will be prepended with evaluation, with
Model.optimizer.iterations being the step in the visualized TensorBoard.
If you have installed TensorFlow with pip, you should be able
to launch TensorBoard from the command line:
tensorboard--logdir=path_to_your_logs
You can find more information about TensorBoard
here.
Args
log_dir
the path of the directory where to save the log files to be
parsed by TensorBoard. e.g. log_dir = os.path.join(working_dir,
'logs') This directory should not be reused by any other callbacks.
histogram_freq
frequency (in epochs) at which to compute
weight histograms for the layers of the model. If set to 0, histograms
won't be computed. Validation data (or split) must be specified for
histogram visualizations.
write_graph
whether to visualize the graph in TensorBoard. The log file
can become quite large when write_graph is set to True.
write_images
whether to write model weights to visualize as image in
TensorBoard.
write_steps_per_second
whether to log the training steps per second
into Tensorboard. This supports both epoch and batch frequency
logging.
update_freq
disabled
profile_batch
Profile the batch(es) to sample compute characteristics.
profile_batch must be a non-negative integer or a tuple of integers.
A pair of positive integers signify a range of batches to profile.
By default, profiling is disabled.
embeddings_freq
frequency (in epochs) at which embedding layers will be
visualized. If set to 0, embeddings won't be visualized.
embeddings_metadata
Dictionary which maps embedding layer names to the
filename of a file in which to save metadata for the embedding layer.
In case the same metadata file is to be
used for all embedding layers, a single filename can be passed.
Examples:
Basic usage:
tensorboard_callback=tf.keras.callbacks.TensorBoard(log_dir="./logs")model.fit(x_train,y_train,epochs=2,callbacks=[tensorboard_callback])# Then run the tensorboard command to view the visualizations.
Profiling:
# Profile a single batch, e.g. the 5th batch.tensorboard_callback=tf.keras.callbacks.TensorBoard(log_dir='./logs',profile_batch=5)model.fit(x_train,y_train,epochs=2,callbacks=[tensorboard_callback])# Profile a range of batches, e.g. from 10 to 20.tensorboard_callback=tf.keras.callbacks.TensorBoard(log_dir='./logs',profile_batch=(10,20))model.fit(x_train,y_train,epochs=2,callbacks=[tensorboard_callback])
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-10-28 UTC."],[],[],null,["# tf.keras.callbacks.TensorBoard\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.11.0/keras/callbacks.py#L2309-L2902) |\n\nEnable visualizations for TensorBoard.\n\nInherits From: [`Callback`](../../../tf/keras/callbacks/Callback) \n\n tf.keras.callbacks.TensorBoard(\n log_dir='logs',\n histogram_freq=0,\n write_graph=True,\n write_images=False,\n write_steps_per_second=False,\n update_freq='epoch',\n profile_batch=0,\n embeddings_freq=0,\n embeddings_metadata=None,\n **kwargs\n )\n\nTensorBoard is a visualization tool provided with TensorFlow.\n\nThis callback logs events for TensorBoard, including:\n\n- Metrics summary plots\n- Training graph visualization\n- Weight histograms\n- Sampled profiling\n\nWhen used in [`Model.evaluate`](../../../tf/keras/Model#evaluate), in addition to epoch summaries, there will be\na summary that records evaluation metrics vs `Model.optimizer.iterations`\nwritten. The metric names will be prepended with `evaluation`, with\n`Model.optimizer.iterations` being the step in the visualized TensorBoard.\n\nIf you have installed TensorFlow with pip, you should be able\nto launch TensorBoard from the command line: \n\n tensorboard --logdir=path_to_your_logs\n\nYou can find more information about TensorBoard\n[here](https://www.tensorflow.org/get_started/summaries_and_tensorboard).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `log_dir` | the path of the directory where to save the log files to be parsed by TensorBoard. e.g. log_dir = os.path.join(working_dir, 'logs') This directory should not be reused by any other callbacks. |\n| `histogram_freq` | frequency (in epochs) at which to compute weight histograms for the layers of the model. If set to 0, histograms won't be computed. Validation data (or split) must be specified for histogram visualizations. |\n| `write_graph` | whether to visualize the graph in TensorBoard. The log file can become quite large when write_graph is set to True. |\n| `write_images` | whether to write model weights to visualize as image in TensorBoard. |\n| `write_steps_per_second` | whether to log the training steps per second into Tensorboard. This supports both epoch and batch frequency logging. |\n| `update_freq` | **disabled** \u003cbr /\u003e | **Warning:** Batch-level summary writing using `update_freq` is currently unsupported. A suggested workaround is shown in the [TensorBoard Scalars tutorial](https://www.tensorflow.org/tensorboard/scalars_and_keras#batch-level_logging). |\n| `profile_batch` | Profile the batch(es) to sample compute characteristics. profile_batch must be a non-negative integer or a tuple of integers. A pair of positive integers signify a range of batches to profile. By default, profiling is disabled. |\n| `embeddings_freq` | frequency (in epochs) at which embedding layers will be visualized. If set to 0, embeddings won't be visualized. |\n| `embeddings_metadata` | Dictionary which maps embedding layer names to the filename of a file in which to save metadata for the embedding layer. In case the same metadata file is to be used for all embedding layers, a single filename can be passed. |\n\n#### Examples:\n\n#### Basic usage:\n\n tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=\"./logs\")\n model.fit(x_train, y_train, epochs=2, callbacks=[tensorboard_callback])\n # Then run the tensorboard command to view the visualizations.\n\n#### Profiling:\n\n # Profile a single batch, e.g. the 5th batch.\n tensorboard_callback = tf.keras.callbacks.TensorBoard(\n log_dir='./logs', profile_batch=5)\n model.fit(x_train, y_train, epochs=2, callbacks=[tensorboard_callback])\n\n # Profile a range of batches, e.g. from 10 to 20.\n tensorboard_callback = tf.keras.callbacks.TensorBoard(\n log_dir='./logs', profile_batch=(10,20))\n model.fit(x_train, y_train, epochs=2, callbacks=[tensorboard_callback])\n\nMethods\n-------\n\n### `set_model`\n\n[View source](https://github.com/keras-team/keras/tree/v2.11.0/keras/callbacks.py#L2476-L2494) \n\n set_model(\n model\n )\n\nSets Keras model and writes graph if specified.\n\n### `set_params`\n\n[View source](https://github.com/keras-team/keras/tree/v2.11.0/keras/callbacks.py#L692-L693) \n\n set_params(\n params\n )"]]