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))
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.
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With