【问题标题】:AssertionError when attempting to import keras related to backend尝试导入与后端相关的 keras 时出现 AssertionError
【发布时间】:2018-01-01 07:00:58
【问题描述】:

所以,在尝试导入keras时,出现如下AssertionError:

    /home/m7nz/anaconda3/envs/ninja-01/lib/python3.6/site-packages/keras/backend/__init__.py in <module>()
     32     assert isinstance(_epsilon, float)
     33     _backend = _config.get('backend', _BACKEND)
---> 34     assert _backend in {'theano', 'tensorflow'}
     35     _image_data_format = _config.get('image_data_format',
     36                                      image_data_format())

AssertionError: 

keras.json如下:

{
"floatx": "float32",
"epsilon": 1e-07,
"backend": "theanos",
"image_data_format": "channels_last"

我已尝试删除 init.py 文件中对 tensorflow 的引用,但错误仍然存​​在。

它在 Linux 机器上,运行 ubuntu 16。使用 Anaconda3。它实际上是在 anaconda 环境中。

感谢您的帮助。

【问题讨论】:

    标签: python tensorflow anaconda keras theano


    【解决方案1】:

    改变

    "backend": "theanos",

    "backend": "theano",
    

    这只是您的 json 文件中的一个错字:-)

    【讨论】:

    • 我还在 json 文件中添加了 "image_dim_ordering": "th",它终于可以工作了。再次感谢您。
    猜你喜欢
    • 2017-11-29
    • 2020-04-22
    • 2019-03-05
    • 2019-10-06
    • 2019-10-31
    • 1970-01-01
    • 2020-03-21
    • 2022-10-22
    • 1970-01-01
    相关资源
    最近更新 更多