AttributeError: module 'tensorflow_core.python.keras.api._v2.keras.backend' has no attribute 'get_session'

Hi,

I’m trying to execute this hello world example (26):
https://docs.nvidia.com/deeplearning/sdk/tensorrt-sample-support-guide/index.html#network_api_pytorch_mnist

But got this error after completing the 5 training epochs:
Traceback (most recent call last):

  • File “model.py”, line 95, in *
  • main()*
  • File “model.py”, line 92, in main*
  • save(model, filename=“models/lenet5.pb”)*
  • File “model.py”, line 78, in save*
  • sess = tf.keras.backend.get_session()*
    AttributeError: module ‘tensorflow_core.python.keras.api._v2.keras.backend’ has no attribute 'get_session

how can i solve it?

this is my keras version:
xavier@xavier-desktop:/usr/src/tensorrt/samples/python/end_to_end_tensorflow_mnist$ sudo pip list | grep Keras
WARNING: The directory ‘/home/xavier/.cache/pip’ or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Keras 2.3.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0

Thanks!