import tensorflow as tf
model = tf.keras.models.load_model(‘path_to_model.h5’)
I’m getting module ‘tensorflow’ has no attribute ‘keras’ error when i try to load the model.
I found another post with similar issue but the solutions given below didn’t work for me.
I was using tensorflow==2.4.1 and everything works fine.
Today I update tensorflow to v2.11.0, and error occurs at code like this:
tensorflow.keras.models.load_model(model_path) # try to load a model
The error says:
AttributeError: module ‘tensorflow’ has no attribute ‘keras’
The same code run fine when I was using tensorflow==2.4.1, how comes this error?
Already tried:
pip install -U tensorflow # tensorflow already up to date
pip install -U keras # already satisfied
Could someone help me?
Hi @Yoganand_Parab , Could you please share the tensorflow and keras version you are using? Thank you.
I have installed following versions of tensorflow and keras on anaconda(win11).
Name: tensorflow
Version: 2.14.0
Name: tensorflow
Version: 2.14.0
Hi @Yoganand_Parab , could you please check the environment in which you have installed tensorflow contains keras package as well if not please try to install keras using pip install keras
. Thank you.
hello, i have the same issue and i have installed keras it doesnt solve it.
Hi @tolishunter23 , Instead of importing keras from tensorflow could you please try by importing keras directly using import keras
. Thank you.