Reputation: 71
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: https://i.sstatic.net/OyUPZ.jpg
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))
Upvotes: 7
Views: 3623
Reputation: 121
I found this from Github for this exact purpose but without using tensorboard. Hope this helps!
Upvotes: 1
Reputation: 10224
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 loss
for 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)
Upvotes: 2