Keras:ImportError:没有名为data_utils的模块
我正在尝试导入模块,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
编辑:
见这里的答案。
-
即使这个答案是正确的,但并不完整。感谢BenJ.的回答,但是TadhgMcDonald-Jensen是第一个在这里为我提供答案的人。
总结一下
我本来是
pip install keras
要安装的keras
,但它没有keras
按照此安装最新版本。这就是为什么我会做这样的事情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
。因为它不是以前的版本。所以,只要
clone
在keras
他们的github上,cd
到它,并运行sudo python setup.py install
将解决这个问题。记住,如果您已经这样做,则必须通过多次执行直到没有此版本
pip installkeras
,以确保已清除所有keras
已安装的版本,然后执行此操作。
pip uninstall keras``keras``sudo python setup.py install