我正在尝试导入模块 keras.utils.data_utils
但它不起作用。但是,我可以 在这里 找到这个模块。它确实存在。为什么我不能导入它,而我可以导入一些其他模块,如 keras.models
和 keras.layers.core
?
cliu@cliu-ubuntu:bin$ python
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> from keras.models import Sequential
>>> from keras.layers.core import Dense, Activation, Dropout
>>> from keras.layers.recurrent import LSTM
>>> from keras.utils.data_utils import get_file
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named data_utils
编辑:
在这里 查看答案。
原文由 fluency03 发布,翻译遵循 CC BY-SA 4.0 许可协议
尽管 这个 答案是正确的,但并不完整。感谢 Ben J. 的回答,但 Tadhg McDonald-Jensen 是第一个在 这里 提供答案的人。
总结一下
我正在使用
pip install keras
安装keras
,但它没有根据 这个 安装最新版本的keras
。 That is why I could do things likefrom keras.models import Sequential
,from keras.layers.core import Dense, Activation, Dropout
, andfrom keras.layers.recurrent import LSTM
but notfrom keras.utils.data_utils import get_file
.因为它不在以前的版本中。SO, just
clone
thekeras
from their github ,cd
into it, and runsudo python setup.py install
will solve this problem.请记住,如果您已经这样做了
pip install keras
,您必须确保清除所有keras
您通过这样做安装的版本keras
e18b2535300cfffbb6700f7eb-1 直到很多时间pip uninstall keras
---
存在,然后执行此操作sudo python setup.py install
。