keras 问题相关集锦

  1. 在对模型可视化的时候提示importerror.
from keras.models import Sequential
import numpy as np
from keras.utils.visualize_util import plot

plot(model, to_file='model5.png', show_shapes=True)

报错结果为:

Using TensorFlow backend.
Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 974, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/deepmind/PycharmProjects/test/keras/test.py", line 5, in <module>
    from keras.utils.visualize_util import plot
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py", line 71, in patched_import
    return original_import(name, *args, **kwargs)
  File "//anaconda/lib/python3.6/site-packages/keras/utils/visualize_util.py", line 14, in <module>
    raise ImportError('Failed to import pydot. You must install pydot'
ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

明明相关包都下载了

pip install pydot pydot-ng pydotplus graphviz

最后的解决方案为

conda install graphviz

目前并不知道区别,但是解决了。

你可能感兴趣的:(问题,Keras)