【问题标题】:Keras isn't using TheanoKeras 没有使用 Theano
【发布时间】:2020-12-14 16:13:27
【问题描述】:

1- 我创建了一个虚拟环境:mkvirtualenv kerasTH

2- 我使用 pip install keras 安装 keras

3- 这是pip list的输出

Package       Version
------------- -------
h5py          2.10.0
joblib        0.16.0
Keras         2.4.3
numpy         1.19.1
Pillow        7.2.0
pip           20.2.2
PyYAML        5.3.1
scikit-learn  0.23.2
scipy         1.5.2
setuptools    49.6.0
six           1.15.0
Theano        1.0.5
threadpoolctl 2.1.0
wheel         0.35.1

当我运行 python 然后 import keras 我收到此错误 ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`

我将.keras/keras.json 文件编辑为具有以下内容:

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

我用过

import os
os.environ['KERAS_BACKEND'] = 'theano'

使用了KERAS_BACKEND='theano' python script.py,但我仍然遇到同样的错误。不知道如何切换到theano,有什么建议吗?

操作系统:Ubuntu 20.04 Python 3.8.2 点 20.2.2 CUDA 版本:11.0

【问题讨论】:

    标签: python tensorflow keras theano


    【解决方案1】:

    Keras 2.4 实际上只是在tf.keras 之上的一个包装器,这意味着它不支持多个后端,只支持 TensorFlow 后端。

    因此您需要使用仍支持多个后端的 Keras 2.3。

    【讨论】:

    猜你喜欢
    • 2016-04-26
    • 2017-06-27
    • 1970-01-01
    • 2017-03-12
    • 1970-01-01
    • 2019-07-30
    • 2018-04-26
    • 2016-09-02
    • 2017-01-28
    相关资源
    最近更新 更多