How do I use the Tensorboard callback of Keras?

前端 未结 10 580
名媛妹妹
名媛妹妹 2020-12-04 04:57

I have built a neural network with Keras. I would visualize its data by Tensorboard, therefore I have utilized:

keras.         


        
相关标签:
10条回答
  • 2020-12-04 05:42

    This is how you use the TensorBoard callback:

    from keras.callbacks import TensorBoard
    
    tensorboard = TensorBoard(log_dir='./logs', histogram_freq=0,
                              write_graph=True, write_images=False)
    # define model
    model.fit(X_train, Y_train,
              batch_size=batch_size,
              epochs=nb_epoch,
              validation_data=(X_test, Y_test),
              shuffle=True,
              callbacks=[tensorboard])
    
    0 讨论(0)
  • 2020-12-04 05:47
    keras.callbacks.TensorBoard(log_dir='./Graph', histogram_freq=0,  
              write_graph=True, write_images=True)
    

    This line creates a Callback Tensorboard object, you should capture that object and give it to the fit function of your model.

    tbCallBack = keras.callbacks.TensorBoard(log_dir='./Graph', histogram_freq=0, write_graph=True, write_images=True)
    ...
    model.fit(...inputs and parameters..., callbacks=[tbCallBack])
    

    This way you gave your callback object to the function. It will be run during the training and will output files that can be used with tensorboard.

    If you want to visualize the files created during training, run in your terminal

    tensorboard --logdir path_to_current_dir/Graph 
    

    Hope this helps !

    0 讨论(0)
  • 2020-12-04 05:47

    If you are using google-colab simple visualization of the graph would be :

    import tensorboardcolab as tb
    
    tbc = tb.TensorBoardColab()
    tensorboard = tb.TensorBoardColabCallback(tbc)
    
    
    history = model.fit(x_train,# Features
                        y_train, # Target vector
                        batch_size=batch_size, # Number of observations per batch
                        epochs=epochs, # Number of epochs
                        callbacks=[early_stopping, tensorboard], # Early stopping
                        verbose=1, # Print description after each epoch
                        validation_split=0.2, #used for validation set every each epoch
                        validation_data=(x_test, y_test)) # Test data-set to evaluate the model in the end of training
    
    0 讨论(0)
  • 2020-12-04 05:48

    You should check out Losswise (https://losswise.com), it has a plugin for Keras that's easier to use than Tensorboard and has some nice extra features. With Losswise you'd just use from losswise.libs import LosswiseKerasCallback and then callback = LosswiseKerasCallback(tag='my fancy convnet 1') and you're good to go (see https://docs.losswise.com/#keras-plugin).

    0 讨论(0)
提交回复
热议问题