在keras可视化模型输出时
from keras.utils import plot_model
plot_model(model, to_file=‘model.png’)
但是提示错误OSError: `pydot` failed to call GraphViz.Please install GraphViz
解决办法:
安装
1.pip install pydot
2.pip install graphviz
仍然报错!!!
修改代码:
1.修改set_prog函数:
def set_prog(self, prog): """Sets the default program. Sets the default program in charge of processing the dot file into a graph. """ path = r'D:swanaconda3envsccksLibraryingraphviz'# 例如我的:pip 安装路径 prog = os.path.join(path, prog) prog += '.exe' #self.prog = prog return prog
2.修改create函数
if prog is None: prog = self.prog assert prog is not None prog = self.set_prog('dot') #新增这行
参考:
https://blog.csdn.net/sinat_40282753/article/details/85046871
https://blog.csdn.net/weixin_41864878/article/details/81095885#commentBox
https://blog.csdn.net/lanchunhui/article/details/49472949
https://graphviz.gitlab.io/_pages/Download/Download_windows.html