8

Attempting to do the following:

import tensorflow as tf
from keras.models import load_model, Model
from keras import backend as K

sess = tf.compat.v1.Session()
K.set_session(sess)

When I run this in Google Colab I get:

RuntimeError: `set_session` is not available when using TensorFlow 2.0.

Does anyone know how to fix this?

Bert Hanz
  • 417
  • 1
  • 7
  • 16

1 Answers1

15

try using the keras backend from the tensorflow path. Your code gives me an error, but this works for me.

import tensorflow as tf
from tensorflow.keras.models import load_model, Model
from tensorflow.python.keras import backend as K

sess = tf.compat.v1.Session()
K.set_session(sess)
Nick
  • 392
  • 1
  • 5