如何使用Keras可视化神经网络架构? [英] How can a neural network architecture be visualized with Keras?

查看:624
本文介绍了如何使用Keras可视化神经网络架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下操作:

#!/usr/bin/env python

import keras
from keras.models import model_from_yaml

model_file_path = 'model-301.yaml'
weights_file_path = 'model-301.hdf5'

# Load network
with open(model_file_path) as f:
    yaml_string = f.read()
model = model_from_yaml(yaml_string)
model.load_weights(weights_file_path)
model.compile(optimizer='adagrad', loss='binary_crossentropy')

# Visualize
from keras.utils.visualize_util import plot

但是,这会导致错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/moose/.local/lib/python2.7/site-packages/keras/utils/visualize_util.py", line 7, in <module>
    if not pydot.find_graphviz():
AttributeError: 'module' object has no attribute 'find_graphviz'

我该如何解决?

注意:可以在Github上找到hdf5和YAML文件.

Note: The hdf5 and the YAML file can be found on Github.

推荐答案

. 您需要安装pydot< = 1.1.0的版本,因为函数find_graphviz pydot-ng ,即

The problem is also referenced on the issues page of the keras project. You need to install a version of pydot <= 1.1.0 because the function find_graphviz was removed in version 1.2.0. Alternatively you could install pydot-ng instead, which is recommended by the keras developers.

这篇关于如何使用Keras可视化神经网络架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆