I am using InceptionV3 with imagenet weights in Keras. The version of Keras I am using is 2.2.4 and Keras-applications is 1.0.8. The tensorflow version is 1.14.0. I am following the standard way of using InceptionV3 for transfer learning, as outlined here. I am getting this error ValueError: Input 0 is incompatible with layer global_average_pooling2d_3: expected ndim=4, found ndim=2. I found a GitHub post where the user was facing the same issue. I followed the suggestion which fixed the issue on the GitHub post, but I have had no such luck. MWE is below
from keras.layers import Input, Dense, Activation, GlobalAveragePooling2D
from keras.models import Model
from keras.applications.inception_v3 import InceptionV3
base_model = InceptionV3(weights='imagenet', include_top='False')
x = base_model.output
x = GlobalAveragePooling2D()(x) # Error appears here
x = Dense(1024, activation='relu')(x)
predictions = Dense(3, activation='softmax')(x)
model = Model(inputs=base_model.input, outputs=predictions)