凯拉斯没有使用Theano

2024-09-30 00:38:03 发布

您现在位置:Python中文网/ 问答频道 /正文

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 pip 20.2.2 CUDA版本:11.0


Tags: installpipimportbackendostensorflow错误虚拟环境
1条回答
网友
1楼 · 发布于 2024-09-30 00:38:03

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

因此,您需要使用Keras2.3,它仍然支持多个后端

相关问题 更多 >

    热门问题