Keras网络可视化方法

  • Keras模型可视化
  • Keras可视化依赖的两个包
  • 参考链接

Keras模型可视化

代码:

from keras.utils import plot_model

plot_model(model, to_file='model.png')

plot_model接收两个可选参数:

  • show_shapes:指定是否显示输出数据的形状,默认为False
  • show_layer_names:指定是否显示层名称,默认为True

一个效果图如下:
这里写图片描述


Keras可视化依赖的两个包

1、Graphviz安装步骤
  • Windows环境下载地址
    这里写图片描述

  • 安装graphviz-2.38.msi到自定义文件夹

  • 添加..\Graphviz2.38\bin路径到系统环境变量Path中

  • cmd界面中运行命令, dot -V
    Keras网络可视化方法-小白菜博客
    如图所示,则Graphviz安装成功。

特别说明:
python中可以用pip直接安装,但是由于graphviz需要添加路径到系统环境变量,所以按照上面步骤直接到位。

pip install graphviz
2、pydot安装
pip install pydot

参考链接
https://keras-cn.readthedocs.io/en/latest/other/visualization/
https://blog.csdn.net/lyb3b3b/article/details/77899258