2016-07-18 52 views
5

tôi thử như sau:Kiến trúc mạng nơron có thể được hình dung như thế nào với 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 

Tuy nhiên, điều này mang lại một lỗi:

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' 

Làm thế nào tôi có thể sửa lỗi này?

Lưu ý: Bạn có thể tìm thấy tệp hdf5 và YAML on Github.

+0

Xem thêm: [Làm thế nào để bạn hình dung kiến ​​trúc mạng nơron?] (Http://datascience.stackexchange.com/q/12851/8820) –

Trả lời

1

Nếu bạn chưa cài đặt gói pydot python - hãy thử cài đặt nó. Nếu bạn có cài đặt lại pydot sẽ giúp bạn giải quyết vấn đề.

+1

'pydot' được cài đặt trong phiên bản 1.2.2. Cài đặt lại nó không giúp ích gì. –

2

Sự cố cũng được tham chiếu trên issues page của dự án keras. Bạn cần cài đặt phiên bản pydot < = 1.1.0 vì chức năng find_graphvizremoved trong phiên bản 1.2.0. Ngoài ra, bạn có thể cài đặt pydot-ng thay thế, đó là recommended bởi các nhà phát triển máy ảnh.

Các vấn đề liên quan