I am doing some task related to image captioning and I have loaded the weights of inception model like this
model = InceptionV3(weights=\'imagenet\')
In my case, replacing
from keras.models import models
with:
from tensorflow.keras.models import models
in my script, fixed this problem.
Change
Import keras.<something>.<something>
to
Import tensorflow.keras.<something>.<something>
where "something" refers to the module you want to import. It worked for me.
Keras integrated into TensorFlow 2.0
The article below cleared this up for me. Key points are:
After recognizing that and making the change, my code samples work with some minor changes here and there. https://www.pyimagesearch.com/2019/10/21/keras-vs-tf-keras-whats-the-difference-in-tensorflow-2-0/
Another cause due to which this is happening is that in tensorflow_backend.py
located in : lib/python3.6/site-packages/keras/backend/
uses tf.compat.v1.get_default_graph for obtaining graph
instead of tf.get_default_graph.
By replacing this in the directory this problem can be solved successfully.
I fixed this problem by replacing tensorflow.keras.* to tensorflow.python.keras.*
Working example:
from tensorflow.python.keras.models import Sequential