系统:Linux
python版本:python3.6
CUDA版本:CUDA 8.0
tensorflow版本:tensorflow 1.4.0
Keras版本:keras 2.1.2
模型可视化plot_model需要安装graphviz以及graphviz的可执行文件和pydot
本人是参考别人博客内容,sudo权限安装
sudo apt-get install graphviz
sudo apt-get install graphviz libgraphviz-dev pkg-config
sudo apt-get install python-pip python-virtualenv
pip install pydot2
安装完成后:各文件位置
A、下载的软件的存放位置:/var/cache/apt/archives
B、安装后软件的默认位置:/usr/share
C、可执行文件位置:/usr/bin
D、配置文件位置:/etc
E、lib文件位置:/usr/lib
所有以上步骤完成,就算安装完成了
接下来找到pydot.py
位置:/home/你的名字/Anaconda3/lib/python3.6/site-packages/pydot.py
注:我的是这个路径,其他人可能不一定相同
检查一下pydot.py文件中find_graphviz()函数中path是否包含‘/usr/share’和‘/usr/bin’
如果都没问题,接下来检查一下解释器
File-Setting-Project Interpreter中有没有graphviz和pydot,因为都要解释器中去执行.py文件
如果有的话,没有问题。如果没有,点击右边绿色的小加号,找到graphviz和pydot再Install一下
这样应该就OK了
可以试一下:
from keras.utils.vis_utils import plot_model
model=Sequential()
********构建模型的过程**********
plot_model(model, to_file='model.png')