UserWarning: The output shape of `ResNet50(include_top=False)` has been changed since Keras 2.2.0

2.2k Views Asked by At

For transfer learning I am using a ResNet50 model pre trained on ImageNet. After removing the last layer I want to use outputs of the layer before the last layer (as the last layer is removed by making top = False) as a feature extractor to train a Logistic Regression classifier. I got this UserWarning (mentioned in the question's title) for the line below:

model = ResNet50(weights='imagenet', include_top = False)

Why this is happening?

3

There are 3 best solutions below

0
Gaurao Mate On

I got the same problem after giving the "include_top = False". Then first I set "incude_top = True", the dataset is downloaded. After that, I set the "include_top = False", the dataset is downloaded and there is no error.

0
Dean On
base_model = ResNet50(include_top=False,weights='imagenet',input_shape = (224,224,3),pooling='avg')

Set the pooling='avg' or 'max'

You can see it in the code from resnet50.py if you go to the warning link

0
Kassem On

According to keras official site: resnet50-function

You can simply use ResNet50 directly from application class, like that:

from keras.applications import ResNet50

model = ResNet50(weights='imagenet', include_top = False)