Reputation: 1
i know from paper:the output of efficientnet b0 is (*,7,7,1280),right?if so,the globalAveragePooling2D will get ndim = 4,instead of 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
Upvotes: 0
Views: 1586
Reputation: 56367
That is because you set include_top
to True
, meaning that classification layers are included in the model, so the output shape of the whole model is (samples, classes)
, that's probably not what you want.
As you want feature maps, you should set include_top
to False
in the instantiation of EfficientNetB0
.
Upvotes: 1