close

呼叫keras的plot_model工具可以將已建好的model,

輸出成圖片檔做保存,

如果環境本身未安裝pydot, graphviz將會無法正常執行plot_model工具,

下方為發生錯誤的原因以及完整的安裝步驟,

 

➢出現如下錯誤表示,未安裝GraphViz套件

OSError: pydot failed to call GraphViz. Please install GraphViz (https://www.graphiz.org/) and ensure that its executables are in the $PATH.

➢出現如下錯誤表示,未完全安裝好GraphViz套件

Exception: "dot.exe" not found in path.

 

完整安裝流程如下:

1. 安裝Graphviz套件

輸入:pip install graphviz

2. 安裝Graphviz Windows安裝包,格式為msi(依據使用者作業系統來做下載)

https://graphviz.orz/download/

3. 安裝pydot套件

輸入:pip install pydot-ng

輸入:pip install pydot==1.2.3

4. 在程式內加入環境變數設置,依據第2項安裝位置做設置

import os

os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz/bin/'

5. 將建好的model保存成圖片

from keras.utils import plot_model

plot_model(model, to_file='model.png', show_layer_names=True, show_shapes=True)

 

arrow
arrow

    楓綺 發表在 痞客邦 留言(0) 人氣()