Keras isn't using Theano

霸气de小男生 提交于 2021-02-05 09:32:30

问题


1- I create a virtual env: mkvirtualenv kerasTH

2- I install keras using pip install keras

3- That's the output for 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

When I run python and then import keras I get this error ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`

I edited the .keras/keras.json file to have the following:

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

I used

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

Used KERAS_BACKEND='theano' python script.py but I am still getting the same error. Not sure how to switch to theano, any suggestions ?

OS: Ubuntu 20.04 Python 3.8.2 pip 20.2.2 CUDA Version: 11.0


回答1:


Keras 2.4 is actually just a wrapper on top of tf.keras, meaning that it does not support multiple backends, only the TensorFlow backend.

So you would need to use Keras 2.3, which does still support multiple backends.



来源:https://stackoverflow.com/questions/63587843/keras-isnt-using-theano

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!