Reputation: 11
I am using Win10Pro, gpu (CUDA 10.1), Python 3.7.5, Tensorflow 2.1.0 and Tensorboard 2.1.0 to run the tensorboard example given on (https://www.tensorflow.org/tensorboard/get_started) using the following code in ipython (after running %load_ext tensorboard in ipython console):
import tensorflow as tf
import datetime
import os
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
def create_model():
return tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(512, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')
])
model = create_model()
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
log_dir=os.path.join("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])
This runs successfully. Afterwards, I typed (%tensorboard --logdir logs/fit) in command prompt and I got the following message:
2020-01-24 11:40:14.612500: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll W0124 11:40:16.549416 8508 plugin_event_accumulator.py:294] Found more than one graph event per run, or there was a metagraph containing a graph_def, as well as one or more graph events. Overwriting the graph with the newest event. Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all TensorBoard 2.1.0 at http://localhost:6006/ (Press CTRL+C to quit).
However, when I go the aforementioned address, there is nothing to see. My log directory has an absolute path: C:\Users\ak39.MEDMA\codes\logs\fit
. Can anyone please help me in visualizing the Tensorboard?
Upvotes: 1
Views: 734
Reputation: 161
Can you try the following: Add the import at the top
from tensorflow.keras.callbacks import TensorBoard, LearningRateScheduler
add an update frequency to the callback
tensorboard_callback = TensorBoard(
log_dir=log_dir,
update_freq='batch',
histogram_freq=1)
Also in the tensorflow guide (https://www.tensorflow.org/tensorboard/get_started) it is advised to start the tensorboard without the % when running it in the command line.
tensorboard --logdir logs/fit
If that does not work, then you could also try saving the checkpoints after each epoch by adding a checkpoint callback:
checkpoint_callback = ModelCheckpoint(
filepath, monitor='val_accuracy', verbose=1,
save_best_only=False, save_weights_only=False,
save_frequency=1)
example:
model.fit(train_dataset,
epochs=3, callbacks=[checkpoint_callback],
validation_data=test_dataset,
validation_freq=1)
Upvotes: 0