Can I use TensorBoard with Google Colab?

前端 未结 19 2944
滥情空心
滥情空心 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: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.

提交回复
热议问题