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

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

Hi @William_Chan, Have you updated tensorflow version to 2.11.0 in the environment where 2.4.1 was currently present or you have created a new environment for 2.11.0? Thank You.

Hey, this is because keras can now be directly called by the import. Just leave the tensorflow infront of your imports out and it should work fine.
So just type: keras.models.load_model(model_path)