python - assert _backend in {'theano' , 'tensorflow' } AssertionError

标签 python tensorflow theano keras

我正在尝试运行 this code ,但出现以下错误:

Traceback (most recent call last):
  File "classifier_from_little_data_script_3.py", line 39, in <module>
    from keras import applications
  File "C:\Python35\lib\site-packages\keras\__init__.py", line 3, in <module>
    from . import activations
  File "C:\Python35\lib\site-packages\keras\activations.py", line 3, in <module>
    from . import backend as K
  File "C:\Python35\lib\site-packages\keras\backend\__init__.py", line 36, in <module>
    assert _backend in {'theano', 'tensorflow'}
AssertionError

我试图寻找此错误的原因,但找不到解决方案。我该如何解决这个问题?

编辑 1

这是 keras.json 文件:

{
    "image_dim_ordering": "tf",
    "epsilon": 1e-07,
    "floatx": "float32",
    "backend": "tf"
}

编辑 2

我已将后端更改为 tensorflow,但出现以下错误:

ValueError: The shape of the input to "Flatten" is not fully defined (got (None, None, 512). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.

我为第二次编辑添加了一个单独的问题,here .

谢谢。

最佳答案

你的 keras.json 应该是这样的

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

注意 "backend": "tensorflow" 与你所拥有的 "backend": "tf"

的区别

关于python - assert _backend in {'theano' , 'tensorflow' } AssertionError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43377203/

相关文章:

python - 当数据表不显示在页面源中时如何抓取

python - Django 应用程序在容器内部运行,但无法解析容器外部的数据库

python - 将整数日期格式转换为人类可读格式

python - 属性错误 : module 'tensorflow' has no attribute 'GraphDef'

machine-learning - 当层不可训练时拟合 keras 模型会产生不一致的结果

python - Theano 中的值错误 : Dimension Mismatch . .

python - 如何在 Python 中制作可排序的数据类型?

python - 检查 Tensor 是否为 Placeholder?

python - 如何使用 tf.train.Checkpoint 保存大量变量

python - Theano共享变量更新导致 `ValueError: length not known`