1. 程式人生 > >plot_model 報錯 "Failed to import pydot. You must install pydot and graphviz for 'pydotprint' to work"

plot_model 報錯 "Failed to import pydot. You must install pydot and graphviz for 'pydotprint' to work"

plot_model 是 keras 中自帶的一個視覺化工具,可以將網路結構生成如下圖所示的圖片。


使用:

from keras.utils import plot_model

plot_model(model,to_file='model.png')

但是有時會報錯:

keras ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

執行pip安裝之後還是會報錯。實際上應該安裝graphviz的二進位制檔案。

如果是Windows或者Linux,在官網

http://www.graphviz.org/download/下載安裝即可。

如果是Mac,使用Homebrew安裝:

brew install graphviz