1. 程式人生 > >python使用plot_model繪製模型圖(解決報錯`pydot` failed to call GraphViz.Please install GraphViz (https://www.gr)

python使用plot_model繪製模型圖(解決報錯`pydot` failed to call GraphViz.Please install GraphViz (https://www.gr)

使用plot_model得先安裝好另外兩個庫,graphviz和pydot

pip install graphviz
pip install pydot
#使用graphviz進行模型的視覺化
import os
from keras.utils.vis_utils import plot_model

#新增graphviz的環境變數(os.pathsep + 'graphviz安裝目錄下的bin目錄')
os.environ["PATH"] += os.pathsep + 'E:/New Folder/bin/'

#繪製模型圖
plot_model(model,to_file = 'model.png',show_shapes = True)

沒有新增環境變數的話會報錯:`pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.