ZeroTwoWaifu
ZeroTwoWaifu

Reputation: 63

from keras.backend.tensorflow_backend import set_session

I am trying to run a code using keras. The program uses from keras.backend.tensorflow_backend import set_session and i am getting the following error:

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?

Upvotes: 4

Views: 9556

Answers (1)

user11530462
user11530462

Reputation:

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.

Upvotes: 5

Related Questions