Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show both Training loss and validation loss on the same graph in tensorboard through keras?

I'm using Keras with the Tensorflow back end to train a CNN, and I'm using tensorboard to visualize the loss functions and accuracy. I would like to see the loss function of both the training data and validation data on the same graph, but I've only found ways to do so when using Tensorflow and not through keras.

Is there a way to do so?

Edit 1: I tried writing loss/acc in the Regex but instead of putting both of the graphs together it shows them side by side like so: http://imgur.com/a/oLIcL

Ive added what I use to log to tensor board:

tbCallBack=keras.callbacks.TensorBoard(log_dir='C:\\logs', histogram_freq=0, write_graph=False, write_images=True, embeddings_freq=0, embeddings_layer_names=None, embeddings_metadata=None)

model.fit_generator(train_generator,
                steps_per_epoch=x_train.shape[0] // batch_size,
                epochs=epochs,
validation_data=(x_test, y_test))
like image 488
yarden Avatar asked Jun 13 '17 07:06

yarden


People also ask

Can you run TensorBoard while training?

You can visualize the model graph, losses, accuracy, etc when your model is under training. It is a very helpful tool that can be used to monitor the model that is getting trained on a large dataset. You can use Tensorboard not only with TensorFlow but also with Keras.

How do you plot a TensorBoard graph?

Select the Graphs dashboard by tapping “Graphs” at the top. You can also optionally use TensorBoard. dev to create a hosted, shareable experiment. By default, TensorBoard displays the op-level graph.

How do you read a TensorBoard plot?

Head over to localhost:6006 to see TensorBoard on your local machine. We can see some of the scalar metrics that are provided by default With the linear Classifier. We can also Expand and Zoom into any of these graphs. Double-clicking allows us to zoom out.

How do you read a TensorBoard histogram?

Simply speaking, if the possible values are in a range of 0.. 9 and you see a spike of amount 10 on the value 0 , this means that 10 inputs assume the value 0 ; in contrast, if the histogram shows a plateau of 1 for all values of 0.. 9 , it means that for 10 inputs, each possible value 0.. 9 occurs exactly once.


1 Answers

You can add a regex in the text box in the upper left corner of the Tensorboard window.

Add acc for accuracy of both train/validation data. Add lossfor the loss values. This works for me for Keras as well as Tensorflow.

Got this from this nice tutorial on TB: https://www.youtube.com/watch?v=eBbEDRsCmv4

As a code snippet I use this:

logdir = "_tf_logs/" + now.strftime("%Y%m%d-%H%M%S") + "/"
tb = TensorBoard(log_dir=logdir)
callbacks=[tb]
...
model.fit(X_train, Y_train, validation_data=val_data, epochs=10, verbose=2, callbacks=callbacks)
like image 146
petezurich Avatar answered Sep 18 '22 13:09

petezurich