from keras.backend.tensorflow_backend import set_session

Viewed 6193

I am trying to run a code using keras. The program uses from keras.backend.tensorflow_backend import set_session and i am getting an underhanded Exception thats says No module named 'keras.backend.tensorflow_backend'; 'keras.backend' is not a package with the following error code File "c:/Users/phili/Desktop/python-projects/test.py", line 15, in <module> from keras.backend.tensorflow_backend import set_session ModuleNotFoundError: No module named 'keras.backend.tensorflow_backend'; 'keras.backend' is not a package

I am using python 3.7 Keras 2.4.3 and tensorflow 2.2.0, is there any solution to the problem i can provide the whole code if needed Thanks in advance

1 Answers

I guess you are importing it incorrectly.

The command to import set_session, for Tensorflow 2.3 (latest version) is shown below.

from tensorflow.compat.v1.keras.backend import set_session

Please find this Colab for working code.

Please refer this Tensorflow Documentation for more information.

Related