問題描述
環境: Win 10、Tensorboard 1.5.1
使用工具: 命令提示符(Doc)、events.out.tfevents.xxx文件
報錯類型:
-
ValueError: GetLogdirSubdirectories: path exists and is not a directory…
-
‘ Tensorboard ’ 不是內部或外部指令也不是可運行的程序或批處理文件。
導師拋給我一個events.out.tfevents.xxx文件時,純潔的我想到,如何用Doc去打開它來呢。然後就踩到了坑,網上找了很多資料也沒有解決。後面刷到一篇博文時才發現這個問題是一個低級錯誤,因此我得進行具體描述,以免繼續踩坑。
1、解決“‘ Tensorboard ’ 不是內部或外部指令也不是可運行的程序或批處理文件”問題
命令提示符窗口下,測試Tensorboard模塊是否可以被調用。
win+R 鍵打開命令提示符窗口,輸入 tensorboard --helpfull 後回車。
C:\Users\imlin> tensorboard --helpfull # 有些版本是 --help
如果彈出的是“”,那麼很可能是環境變量的配置問題。當然我也遇到了此問題,我直接通過卸載並重安裝暴力解決了(此處如有新方法,希望看客大佬們留言討論)。
暴力方法: 卸載原tensorflow、tensorboard等,再重安裝tensorflow:
# 以下爲 pip 操作,如果之前安裝tensorflow時用的是conda,那麼如下指令只需將‘pip’改爲‘conda’即可
C:\Users\imlin> pip list # 查看pip中的所有包;如果使用的是conda,那麼可以‘conda list’
Package Version
---------------------- -----------
tensorflow 1.5.0
tensorboard 1.5.1
C:\Users\imlin> pip uninstall tensorflow tensorboard # 刪除
...
Proceed (y/n)? y # 鍵入 y
...
Successfully uninstalled tensorflow-1.5.0
C:\Users\imlin> pip install tensorflow == 1.5 # 安裝tensorflow1.5,會自動同時安裝tensorboard
Collecting tensorflow==1.5
Downloading
|████████████████████████████████| 31.1MB 344kB/s
|████████████████████████████████| 3.0 MB 547 kB/s
...
Successfully installed tensorflow-1.5.0 tensorflow-tensorboard-1.5.1
C:\Users\imlin> tensorboard --helpful # 再次鍵入測試指令,tensorboard成功被調用!
2、解決 “ValueError: GetLogdirSubdirectories: path exists and is not a directory…”問題
命令提示符窗口下,測試Tensorboard模塊是否可以查看張量結構圖。
C:\Users\imlin> tensorboard --logdir = 文件路徑 # 文件路徑即爲張量圖的保存路徑
錯誤示範:
# 假如 events.out.tfevents.xxx 文件放在桌面上的文件夾 test 裏,
C:\Users\imlin> tensorboard --logdir =.\C:\User\用戶\Desktop\test\events.out.tfevents.xxx
# 報錯
ValueError: GetLogdirSubdirectories: path exists and is not a directory, C:\User...
# 系統會照常返回網址,但打開瀏覽器,輸入如下網址並不會成功查看張量圖
TensorBoard 1.5.1 at http://DESKTOP-IPLRV4I:6006 (Press CTRL+C to quit)
錯誤原因: 輸入文件路徑時,直接指向了文件,所以出錯了!
正確做法:
# 假如 events.out.tfevents.xxx 文件放在桌面上的文件夾 test 裏
C:\Users\imlin> tensorboard --logdir =.\C:\User\用戶\Desktop\test # 直接指定events的文件夾
# 獲得返回的網址,複製到瀏覽器後打開即可看到張量圖
TensorBoard 1.5.1 at http://DESKTOP-IPLRV4I:6006 (Press CTRL+C to quit)