【发布时间】: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