Q: Colab官方支援TensorBoard嗎?

A: 不支援,但是可以非官方的方式安裝[0]

以下為安裝步驟:

  1. 在 colab執行以下兩行代碼,將會看到一連串拷貝與解壓縮的程序
!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip ngrok-stable-linux-amd64.zip
  1. 在 colab執行以下代碼,其中'./log'表示TensorFlow event檔存檔的資料夾,並且執行完以下代碼後,TensorBoard會在背景執行。
LOG_DIR = './log'
get_ipython().system_raw(
    'tensorboard --logdir {} --host 0.0.0.0 --port 6006 &'
    .format(LOG_DIR)
)
get_ipython().system_raw('./ngrok http 6006 &')

(event檔是在執行TensorFlow程式執行後產生的檔案,通常是程式中使用tf.train.SummaryWriter和tf.summary.FileWriter等函式的結果。檔名格式如下events.out.tfevents.xxxxx。)

  1. 最後,執行以下代碼,將會輸出一個URL連結,利用瀏覽器開啟之後將會啟動TensorBoard。
! curl -s http://localhost:4040/api/tunnels | python3 -c \
    "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"

[0] https://www.dlology.com/blog/quick-guide-to-run-tensorboard-in-google-colab/

results matching ""

    No results matching ""