Tensorboard is an interactive visualization tool that reads log files and helps you track experiment metrics.
For it to work with Keras's
model.fit() method you need to add Tensorboard callback to
log_dir="logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(
When you have your own training loop you can define a summary writer and use it to write a summary like this:
current_time = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
train_log_dir = 'logs/gradient_tape/' + current_time + '/train'
test_log_dir = 'logs/gradient_tape/' + current_time + '/test'
train_summary_writer = tf.summary.create_file_writer(train_log_dir)
test_summary_writer = tf.summary.create_file_writer(test_log_dir)
for epoch in range(EPOCHS):
for (x_train, y_train) in train_dataset:
train_step(model, optimizer, x_train, y_train)
tf.summary.scalar('loss', train_loss.result(), step=epoch)
tf.summary.scalar('accuracy', train_accuracy.result(), step=epoch)
In any case, you will need to provide a log directory to run Tensorboard. (It doesn't pop up by itself when you train your network. You will have to run it separately. You can run it while training to monitor metrics at the end of each loop).
tensorboard --logdir yourmodel/logs/dir
If you want to make it work with Jupyter notebook you will have to load the Extention and then run magic command
%tensorboard --logdir yourmodel/logs/dir
The code is taken from Tensorboard's getting started link. I hope it helps you understand how it works. Otherwise, you can visit these links. 1, 2