Search code examples
pythontensorflowkerasneural-networktensorboard

Tensorboard shows blank page in Chrome


I'm new to TensorFlow and Tensorboard and when I run the below code, the model trains and returns its outputs fine, however Tensorboard shows a blank page in the browser.

import pandas as pd
import os
import tensorflow as tf
from time import time
from tensorflow.python.keras.layers.core import Dense
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import LSTM
from tensorflow.python.keras.callbacks import TensorBoard
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
import numpy as np

model = Sequential()
model.add(LSTM(units=20, return_sequences=True, input_shape=(1, 7), activation='softsign'))
model.add(LSTM(units=50, return_sequences=True, activation='softsign'))
model.add(LSTM(units=50, return_sequences=True, activation='softsign'))
model.add(LSTM(units=50, return_sequences=True, activation='softsign'))
model.add(LSTM(units=20, activation='softsign'))
model.add(Dense(units=1, activation='sigmoid'))

model.compile(loss='mse', optimizer='Nadam',metrics=['mse'])

tensorboard = TensorBoard(log_dir="logs/fit")

result = model.fit(X_train, Y_train, batch_size=200, epochs=5, validation_split=0.1, verbose=1, callbacks=[tensorboard])

I instantiate TensorBoard using tensorboard --logdir=logs/ in the PyCharm terminal and open Tensorboard in Chrome (http://localhost:6006/ ). However the page is blank and shows no output (not even the orange header of Tensorboard).

Any help would be very much appreciated!

Thanks.


Solution

  • For the benefit of community here am posting answer

    import pandas as pd
    import os
    import tensorflow as tf
    from time import time
    from tensorflow.python.keras.layers.core import Dense
    from tensorflow.python.keras.models import Sequential
    from tensorflow.python.keras.layers import LSTM
    from tensorflow.python.keras.callbacks import TensorBoard
    import matplotlib.pyplot as plt
    from sklearn.preprocessing import MinMaxScaler
    import numpy as np
    
    model = Sequential()
    model.add(LSTM(units=20, return_sequences=True, input_shape=(1, 7), activation='softsign'))
    model.add(LSTM(units=50, return_sequences=True, activation='softsign'))
    model.add(LSTM(units=50, return_sequences=True, activation='softsign'))
    model.add(LSTM(units=50, return_sequences=True, activation='softsign'))
    model.add(LSTM(units=20, activation='softsign'))
    model.add(Dense(units=1, activation='sigmoid'))
    
    model.compile(loss='mse', optimizer='Nadam',metrics=['mse'])
    
    tensorboard = TensorBoard(log_dir="logs/fit")
    
    result = model.fit(X_train, Y_train, batch_size=200, epochs=5, validation_split=0.1, verbose=1, callbacks=[tensorboard])
    
    %load_ext tensorboard
    %tensorboard --logdir logs