Data Science Asked on July 9, 2021
I tried the sample code form the link below.
Get started with TensorBoard | TensorFlow
It pretty much worked fine; just had to make a couple tweaks to get it working on my machine. I was a little surprised to find that it ran just like normal Python code. I thought TensorFlow pops up an interactive GUI, called TensorBoard, and I thought you can interact with this visual interface. When I run the code from the link above, all I have is a command line interface. There is no TensorBoard, no graphics, no GUI, nothing but Python code. Is there a special command that need to be executed to make the TensorBoard work? Is there some additional step that I need to run? I’d appreciate any/all guidance on this.
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 model.fit()
method.
log_dir="logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(
log_dir=log_dir,
histogram_freq=1)
model.fit(x=x_train,
y=y_train,
epochs=5,
validation_data=(x_test, y_test),
callbacks=[tensorboard_callback])
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)
with train_summary_writer.as_default():
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
Answered by Vikas Bhandary on July 9, 2021
As per my experience, Tensorboard not behaving correctly on Windows machine. For example, if you want to see or put a break-point on a particular condition during model training, at least I faced lots of challenges.
On Ubuntu it's working perfectly fine for the cases where I faced issue on Windows, although I still have to explore a lot on its functionality.
So as per my suggestion, try Tensorboard on Ubuntu.
Answered by vipin bansal on July 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP