Can we get rid of set_session in Tensorflow 2.0?

Viewed 2244

I'm trying to migrate code from Tensorflow 1.13 to Tensorflow 2.0 and I'm having issues with the session declaration step.

For now, I replaced tf.keras.backend.set_session by tf.compat.v1.keras.backend.set_session.

config = tf.compat.v1.ConfigProto()

config.gpu_options.allow_growth = True
if self._gpu_fraction:
    config.gpu_options.per_process_gpu_memory_fraction = self._gpu_fraction
sess = tf.compat.v1.Session(config=config)
tf.compat.v1.keras.backend.set_session(sess)

The code is running but I get a warning: The name tf.keras.backend.set_session is deprecated. Please use tf.compat.v1.keras.backend.set_session instead.

I understood that sessions evolved a lot with Tensorflow 2 but I'm not sure if I can/should get rid of this set_session. I'm also not sure about the warning: is tf.compat.v1.keras.backend.set_session calling the old tf.keras.backend.set_session?

Thank you for any guidance you can provide!

0 Answers
Related