本机环境:
- cudatoolkit = 9.0
- cudnn = 7.6.5
- tensorflow-gpu = 1.12.0
- keras = 2.2.4
1、安装pydot 和 graphviz 包,保存模型的图片
安装pydot包,会自动安装依赖的包 graphviz
conda install pydot
结果安装完之后运行,导入tensorflow包出现错误:UserWarning: h5py is running against HDF5 1.10.5 when it was built against 1.10.6, this may cause problems!
这是因为tensorflow依赖的是1.10.5版本,现在是1.10.6版本。所以需要卸载h5py,重新安装
pip uninstall h5py pip install h5py==1.10.5
之后就能正常运行
在model.compile()之后添加以下语句
from keras.utils import plot_model plot_model(model,to_file="model.png")
就能保存模型结构



