Can I use TensorBoard with Google Colab?

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

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

19条回答
  •  离开以前
    2020-11-27 10:57

    There is an alternative solution but we have to use TFv2.0 preview. So if you don't have problems with the migration try this:

    install tfv2.0 for GPU or CPU (TPU no available yet)

    CPU
    tf-nightly-2.0-preview
    GPU
    tf-nightly-gpu-2.0-preview

    %%capture
    !pip install -q tf-nightly-gpu-2.0-preview
    # Load the TensorBoard notebook extension
    # %load_ext tensorboard.notebook # For older versions
    %load_ext tensorboard
    

    import TensorBoard as usual:

    from tensorflow.keras.callbacks import TensorBoard

    Clean or Create folder where to save the logs (run this lines before run the training fit())

    # Clear any logs from previous runs
    import time
    
    !rm -R ./logs/ # rf
    log_dir="logs/fit/{}".format(time.strftime("%Y%m%d-%H%M%S", time.gmtime()))
    tensorboard = TensorBoard(log_dir=log_dir, histogram_freq=1)
    

    Have fun with TensorBoard! :)

    %tensorboard --logdir logs/fit

    Here the official colab notebook and the repo on github

    New TFv2.0 alpha release:

    CPU
    !pip install -q tensorflow==2.0.0-alpha0 GPU
    !pip install -q tensorflow-gpu==2.0.0-alpha0

提交回复
热议问题