keras 的可视化

来源:互联网 发布:ssh2框架搭建实例源码 编辑:程序博客网 时间:2024/06/07 05:40

依赖安装

基础环境:

  • keras.__version__ 2.0.8
  • python sys.version 3.5.4
  • windows 10

安装依赖

  • GraphViz
    Graph Visualization Software, 下载地址. 记得添加C:\Program Files (x86)\Graphviz2.38\bin 到环境变量.
# 可以使用这个代码片来验证安装成功与否.# 它画出的图像见 图1from graphviz import Digraphdot = Digraph(comment='The Round Table')dot.node('A', 'King Arthur')dot.node('B', 'Sir Bedevere the Wise')dot.node('L', 'Sir Lancelot the Brave')dot.edges(['AB', 'AL'])dot.edge('B', 'L', constraint='false')print(dot.source)dot.render('test-output/round-table.gv', view=True)

这里写图片描述
图1 上述示例代码画出的图像

  • pydot_ng
    pip install pydot_ng

然后重启IDE.

模型拓扑可视化

# 使用下面的简单方法, 在model.compile()之后调用, 即可绘图from keras.utils import plot_modelplot_model(semantic_model, to_file='model.png',show_shapes='True')

这里写图片描述
figure 自己设计的TextCNN 的网络拓扑

原创粉丝点击