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
Keras2.4实际上只是
tf.keras
之上的一个包装器,这意味着它不支持多个后端,只支持TensorFlow后端因此,您需要使用Keras2.3,它仍然支持多个后端
相关问题 更多 >
编程相关推荐