Can I use TensorBoard with Google Colab?

前端 未结 19 2799
滥情空心
滥情空心 2020-11-27 10:43

Is there any way to use TensorBoard when training a TensorFlow model on Google Colab?

相关标签:
19条回答
  • 2020-11-27 11:03

    Here's an easier way to do the same ngrok tunneling method on Google Colab.

    !pip install tensorboardcolab
    

    then,

    from tensorboardcolab import TensorBoardColab, TensorBoardColabCallback
    
    tbc=TensorBoardColab()
    

    Assuming you are using Keras:

    model.fit(......,callbacks=[TensorBoardColabCallback(tbc)])
    

    You can read the original post here.

    0 讨论(0)
  • 2020-11-27 11:06

    To join @solver149 answer, here is a simple example how to use TensorBoard in google colab

    1.Create the Graph,ex:

    a = tf.constant(3.0, dtype=tf.float32)
    b = tf.constant(4.0) 
    total = a + b
    

    2. Install Tensorboard

    !pip install tensorboardcolab # to install tensorboeadcolab if it does not it not exist
    

    ==> Result in my case :

    Requirement already satisfied: tensorboardcolab in /usr/local/lib/python3.6/dist-packages (0.0.22)
    

    3. Use it :)

    Fist of all import TensorBoard from tensorboaedcolab (you can use import* to import everything at once), then create your tensorboeardcolab after that attach a writer to it like this :

    from tensorboardcolab import * 
    tbc = TensorBoardColab() # To create a tensorboardcolab object it will automatically creat a link
    writer = tbc.get_writer() # To create a FileWriter
    writer.add_graph(tf.get_default_graph()) # add the graph 
    writer.flush()
    

    ==> Result

    Using TensorFlow backend.
    
    Wait for 8 seconds...
    TensorBoard link:
    http://cf426c39.ngrok.io
    

    4.Check the given link :D

    This example was token from TF guide : TensorBoard.

    0 讨论(0)
  • 2020-11-27 11:07

    TensorBoard works with Google Colab and TensorFlow 2.0

    !pip install tensorflow==2.0.0-alpha0 
    %load_ext tensorboard.notebook
    
    0 讨论(0)
  • 2020-11-27 11:09

    Many of the answers here are now obsolete. So will be mine I'm sure in a few weeks. But at the time of this writing all I had to do is run these lines of code from colab. And tensorboard opened up just fine.

    %load_ext tensorboard
    %tensorboard --logdir logs
    
    0 讨论(0)
  • 2020-11-27 11:09

    I am using tensorflow==1.15.

    %load_ext tensorboard
    %tensorboard --logdir /content/logs
    

    works for me.

    /content/logs
    

    is the path of my logs in google drive.

    0 讨论(0)
  • 2020-11-27 11:10

    According to the documentation all you need to do is this:

    %load_ext tensorboard
    !rm -rf ./logs/ #to delete previous runs
    %tensorboard --logdir logs/
    tensorboard = TensorBoard(log_dir="./logs")
    

    And just call it in the fit method:

    model.fit(X_train, y_train, epochs = 1000,
             callbacks=[tensorboard], validation_data=(X_test, y_test))
    

    And that should give you something like this:

    I can't post a picture yet so use the link.

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