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,下载链接:http://183.240.9.20/softdl.360tpcdn.com/graphviz/graphviz_2.39.20150331.msi

#使用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.

python使用plot_model绘制模型图(解决报错`pydot` failed to call GraphViz.Please install GraphViz (https://www.gr)_第1张图片

你可能感兴趣的:(机器学习)