【报错】Input 0 is incompatible with layer flatten_5: expected min_ndim=3, found ndim=2
【原因】使用预训练的模型,但是指定了pooling参数
【解决】调用预训练模型时,不要指定pooling参数,去掉即可
# 报错的代码base_model = vgg16.VGG16(include_top=False, weights='imagenet', pooling='avg', input_shape=(224, 224, 3))# 修改后
base_model = vgg16.VGG16(include_top=False, weights='imagenet', input_shape=(224, 224, 3))