Reputation: 419
I installed Keras using Pip and when I am trying to import modules from Keras, it gives me an assertion error on utils and init modules.
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-48-eda57b582878> in <module>()
----> 1 from keras.callbacks import LambdaCallback
C:\ProgramData\Anaconda3\lib\site-packages\keras\__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\__init__.py in <module>()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\conv_utils.py in <module>()
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
C:\ProgramData\Anaconda3\lib\site-packages\keras\backend\__init__.py in <module>()
34 assert isinstance(_epsilon, float)
35 _backend = _config.get('backend', _BACKEND)
---> 36 assert _backend in {'theano', 'tensorflow', 'cntk'}
37 _image_data_format = _config.get('image_data_format',
38 image_data_format())
AssertionError:
I found a similar question in SOF and checked
python -c "from keras import backend"
in cmd prompt and it gives me the following error.
C:\ProgramData\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\ProgramData\Anaconda3\lib\site-
packages\keras\backend\__init__.py", line 36, in <module>
assert _backend in {'theano', 'tensorflow', 'cntk'}
AssertionError
Keras.json:
{
"image_dim_ordering": "tf",
"backend": "mxnet",
"epsilon": 1e-07,
"floatx": "float32"
}
What should I be changing in these modules to avoid this error?
Thanks in Advance.
Upvotes: 0
Views: 690
Reputation: 77494
Based on your update with the contents of your keras.json
file, it appears you have set the backend to "mxnet"
, but this is not a permitted backend of Keras.
Change this value to one of "tensorflow"
, "theano"
, or "cntk"
and be sure you have that corresponding package also installed. Save the file and try again.
Upvotes: 2