from keras.utils import plot_model plot_model(model)
出现错误:
ImportError: Failed to importpydot
. Please installpydot
. For example withpip install pydot
.
继续查阅:
并且按照顺序:
Edit:Try uninstalling all pydot related modules and graphiviz, then reinstall in the following order:(如果很混乱,就全部重装,按照以下顺序再安装一遍)
我装了pydotplus还是不行,继续,尝试这种方法保存model也可以_只是保存的model流程图不够全面。
1 import keras 2 import pydot as pyd 3 from IPython.display import SVG 4 from keras.utils.vis_utils import model_to_dot 5 6 keras.utils.vis_utils.pydot = pyd 7 8 #Visualize Model 9 10 def visualize_model(model): 11 return SVG(model_to_dot(model).create(prog=‘dot‘, format=‘svg‘)) 12 #create your model 13 #then call the function on your model 14 visualize_model(model)
Just in case someone using windows might need it, modify the pydot.py file. It should be in <python_install_path>\Lib\Site-packages\pydot.py. Besides pip install pydot and pip install graphviz, also install graphviz software. And add the software bin directory to the system‘s path. And in class Dot(Graph), change self.prog = ‘dot‘ to self.prog = ‘dot.exe‘
按照这个方案,先修改pydot.py,加上.exe
然后把exe文件的路径加入系统
我的是C:\Users\user\Anaconda3\Library\bin\graphviz
然后就解决了!~~~
keras 显示错误 无法保存model图片_ImportError: Failed to import pydot.
原文:https://www.cnblogs.com/Roxy121314/p/12120915.html