|TensorFlow 1 version||View source on GitHub|
Enable visualizations for TensorBoard.
tf.keras.callbacks.TensorBoard( log_dir='logs', histogram_freq=0, write_graph=True, write_images=False, update_freq='epoch', profile_batch=2, embeddings_freq=0, embeddings_metadata=None, **kwargs )
Used in the notebooks
|Used in the guide||Used in the tutorials|
TensorBoard is a visualization tool provided with TensorFlow.
This callback logs events for TensorBoard, including:
- Metrics summary plots
- Training graph visualization
- Activation histograms
- Sampled profiling
If you have installed TensorFlow with pip, you should be able to launch TensorBoard from the command line:
You can find more information about TensorBoard here.
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir="./logs") model.fit(x_train, y_train, epochs=2, callbacks=[tensorboard_callback]) # run the tensorboard command to view the visualizations.
# 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]) # Now run the tensorboard command to view the visualizations (profile plugin). # 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]) # Now run the tensorboard command to view the visualizations (profile plugin).
||the path of the directory where to save the log files to be parsed by TensorBoard.|
||frequency (in epochs) at which to compute activation and 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.|
||whether to visualize the graph in TensorBoard. The log file can become quite large when write_graph is set to True.|
||whether to write model weights to visualize as image in TensorBoard.|
||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, it will profile the second batch. Set profile_batch=0 to disable profiling.|
||frequency (in epochs) at which embedding layers will be visualized. If set to 0, embeddings won't be visualized.|
||a dictionary which maps layer name to a file name in which metadata for this embedding layer is saved. See the details about metadata files format. In case if the same metadata file is used for all embedding layers, string can be passed.|
||If histogram_freq is set and no validation data is provided.|
set_model( model )
Sets Keras model and writes graph if specified.
set_params( params )