当前位置: 代码迷 >> 综合 >> Input 0 is incompatible with layer flatten_1: expected min_ndim=3, found ndim=2
  详细解决方案

Input 0 is incompatible with layer flatten_1: expected min_ndim=3, found ndim=2

热度:89   发布时间:2023-12-15 17:31:41.0

【报错】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))

 

  相关解决方案