Error after updating TensorFlow: module 'keras._tf_keras.keras.backend' has no attribute 'set_session

I was using TMVA and pyTMVA from my locally installed ROOT to run TensorFlow, and train models. It was working great, and I was able to apply the models using the variables in my root branches. Then I (foolishly) updated my TensorFlow via pip, and I keep getting this error:

module ‘keras._tf_keras.keras.backend’ has no attribute 'set_session

whenever I try training new models in ROOT TMVA, or when I want to apply my models and get a Keras output. Anyone have an idea on how to fix it? After Googling around a bit, people online are saying the latest version of TensorFlow got rid of get_session()? But how do I remove this? Thank you for any help, it’s much appreciated…

Hi Ammar,

Have you thought about downgrading TF?

Cheers,
D

PS
@moneta

Yes I ended up downgrad tensorflow (2.13) and it worked, thankfully. Well, I’ll still leave this up for new users. Thanks!

Hello,
we are currently not supporting Tensorflow version >= 2.16, which come with the new Keras (version 3.0). I will provide the support for new Tensorflow for the next ROOT release in November.

Lorenzo