x = Concatenate(axis = 1)([out1,out2,out3,out4])ValueError:“ Concatenate”层要求输入的形状与concat轴一致,但形状匹配

时间:2019-10-05 12:53:56

标签: python keras

我在互联网上找到了此代码,并尝试通过添加EfficientNetB3进行扩展,但出现此错误。我不懂这种技术,它有名字吗?

#define vgg + resnet50 + densenet
model1 = create_base_model(vgg16.VGG16, (224, 224), vgg16.preprocess_input)
model2 = create_base_model(resnet50.ResNet50, (224, 224), resnet50.preprocess_input)
model3 = create_base_model(inception_v3.InceptionV3, (299, 299), inception_v3.preprocess_input)

model4 = EfficientNetB3(weights='imagenet', include_top=False, input_shape=(300, 300, 3))
# model5 = EfficientNetB5(weights='imagenet', include_top=False, input_shape=(456, 456, 3))

model1.trainable = False
model2.trainable = False
model3.trainable = False
model4.trainable = False
# model5.trainable = False

inpA = Input(shape = (224, 224, 3))
inpB = Input(shape = (299, 299, 3))
inpC = Input(shape = (300, 300, 3))
# inpD = Input(shape = (456, 456, 3))

out1 = model1(inpA)
out2 = model2(inpA)
out3 = model3(inpB)
out4 = model4(inpC)
# out5 = model5(inpD)

x = Concatenate(axis=1)([out1, out2, out3, out4])                
x = Dropout(0.2)(x)
x = Dense(1, activation='sigmoid')(x)

ValueError: A `Concatenate` layer requires inputs with matching shapes
 except for the concat axis. Got inputs shapes: [(None, 512), 
(None, 2048), (None, 2048), (None, 10, 10, 1536)]

谢谢。

0 个答案:

没有答案