Using TensorBoard with Machine Learning

TensorBoard is a web-based tool to provide the visualizations and metrices needed during the machine learning process. TensorBoard is tightly integrated with TensorFlow and can be used seamlessly with it. It is highly efficient to track metrices like loss and accuracy, visualizing the model graph, histograms, and much more. Let’s understand more about how to collect metrices on TensorBoard and analyze those.

TensorBoard as callback

Consider the animal-building classification scenario in our post, Exploring CNN with TensorFlow & Keras. We have included TensorBoard as one of the callbacks while training the model. Callback is a tool to customize and extend the behavior of a model during training, evaluation, or inference, such as, model checkpointing (to periodically save your model during training), data augmentation (to increase the diversity of the training dataset), learning rate adjustments (dynamically adjust the learning rate during training based on certain conditions), TensorBoard (log metrics, visualizations, and other information to TensorBoard for monitoring of the training process) etc.

As per the above code, metrices will be saved in the specified log directory with the training process.

Visualizing the metrics

You have to run the TensorBoard with the command in terminal as, TensorBoard –logdir=<your_log_location>. By default, TensorBoard will be started on port 6006 (as mentioned before, TensorBoard is a tool, which runs as a web application on server).

Below are the augmented images, accuracy and loss graphs captured in TensorBoard.

TensorBoard can also be used to display various metrics, obtained by experimentation on different hyperparameters, such as, learning rates, optimizers, dropout rate, batch size etc. You may need to experiment with the combinations of different hyperparameters, in order to achieve best accuracy of the model.

More information about experimenting with different hyper parameters and visualize the results on HParam dashboard in TensorBoard, please refer to the post, Tuning Hyperparameters and visualizing on TensorBoard.

There are various other scenarios also available, where TensorBoard can be very helpful, such as, viewing model checkpoints, visualizing histograms etc.

Leave a Reply