# Error after updating TensorFlow: module 'keras.\_tf\_keras.keras.backend' has no attribute 'set\_session

**URL:** <https://root-forum.cern.ch/t/error-after-updating-tensorflow-module-keras-tf-keras-keras-backend-has-no-attribute-set-session/60640>\
**Category:** TMVA\
**Created:** [August 29, 2024, 1:35am UTC](https://root-forum.cern.ch/t/error-after-updating-tensorflow-module-keras-tf-keras-keras-backend-has-no-attribute-set-session/60640 "2024-08-29T01:35:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abayyari](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abayyari/32/35034_2.png) [@abayyari](https://root-forum.cern.ch/u/abayyari)\
**Post date:** [August 29, 2024, 1:35am UTC](https://root-forum.cern.ch/t/error-after-updating-tensorflow-module-keras-tf-keras-keras-backend-has-no-attribute-set-session/60640/1 "2024-08-29T01:35:47Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [August 29, 2024, 3:42am UTC](https://root-forum.cern.ch/t/error-after-updating-tensorflow-module-keras-tf-keras-keras-backend-has-no-attribute-set-session/60640/2 "2024-08-29T03:42:27Z")

</div>

Hi Ammar,

Have you thought about downgrading TF?

Cheers,  
D

PS  
@moneta

---

<div class="post-metadata">

**Author:** ![abayyari](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abayyari/32/35034_2.png) [@abayyari](https://root-forum.cern.ch/u/abayyari)\
**Post date:** [August 29, 2024, 4:43am UTC](https://root-forum.cern.ch/t/error-after-updating-tensorflow-module-keras-tf-keras-keras-backend-has-no-attribute-set-session/60640/3 "2024-08-29T04:43:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [August 29, 2024, 7:34am UTC](https://root-forum.cern.ch/t/error-after-updating-tensorflow-module-keras-tf-keras-keras-backend-has-no-attribute-set-session/60640/4 "2024-08-29T07:34:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LUIS\_FERNANDO\_OLAYA](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/luis_fernando_olaya/32/39313_2.png) [@LUIS\_FERNANDO\_OLAYA](https://root-forum.cern.ch/u/LUIS_FERNANDO_OLAYA)\
**Post date:** [September 2, 2025, 2:19pm UTC](https://root-forum.cern.ch/t/error-after-updating-tensorflow-module-keras-tf-keras-keras-backend-has-no-attribute-set-session/60640/5 "2025-09-02T14:19:43Z")

</div>

Hello,

I need help with the tutorial of TMVA\_ CNN\_Classification, I get an error when running the code.

Attributed Error: **module ‘keras.\_tf\_keras.keras.backend’ has no attribute ‘set\_session’. Did you mean: ‘set\_epsilon’? : Failed to run python code.**

I am usisng root 6.36.04 version and Ubuntu 24.04 LTS version

I really appreciate your help

thanks.
