我从论文中知道:efficientnet b0 的输出是 (*,7,7,1280),对吗?如果是这样,那么 globalAveragePooling2D 将得到 ndim = 4,而不是 2。
model=Sequential()
inputS=(height,width,depth)
chanDim=-1
model.add(EfficientNetB0(inputS, include_top=True, weights='imagenet'))
model.add(GlobalAveragePooling2D())
model.add(Dense(1024))
model.add(Activation("swish"))
model.add(BatchNormalization(axis=chanDim))
model.add(Dropout(0.25))
model.add(Dense(256))
model.add(Activation("swish"))
model.add(BatchNormalization(axis=chanDim))
model.add(Dropout(0.25))
model.add(Dense(32))
model.add(Activation("tanh"))
model.add(BatchNormalization(axis=chanDim))
model.add(Dropout(0.25))
model.add(Dense(classes))
model.add(Activation("softmax"))
return model
ValueError: Input 0 is incompatible with layer global_average_pooling2d_2: expected ndim=4, found ndim=2