AttributeError: module 'tensorflow.keras' has no attribute '__version__'

import sys

import tensorflow.keras
import pandas as pd
import sklearn as sk
import tensorflow as tf

print(f"Tensor Flow Version: {tf.version}“)
print(f"Keras Version: {tensorflow.keras.version}”)
print(f"Python {sys.version}“)
print(f"Pandas {pd.version}”)
print(f"Scikit-Learn {sk.version}")
gpu = len(tf.config.list_physical_devices(‘GPU’))>0
print(“GPU is”, “available” if gpu else “NOT AVAILABLE”)

And here’s the output -
Tensor Flow Version: 2.15.0

AttributeError Traceback (most recent call last)
Cell In[5], line 10
7 import tensorflow as tf
9 print(f"Tensor Flow Version: {tf.version}“)
—> 10 print(f"Keras Version: {tensorflow.keras.version}”)
11 print()
12 print(f"Python {sys.version}")

AttributeError: module ‘tensorflow.keras’ has no attribute ‘version
output after I comment the line - print(f"Keras Version: {tensorflow.keras.version}")
Tensor Flow Version: 2.15.0

Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:35:25) [Clang 16.0.6 ]
Pandas 2.1.4
Scikit-Learn 1.4.0
GPU is available

Why isn’t the Keras version shown? Please help me out with this.


This text will be hidden

Hi @yen, To get the keras version you you can import keras directly and can get the version
Thank You.