我有8个CNN模型model1,model2,model3,model4,model5,model6,model7,model8,每个模型都具有conv2d,激活,maxpooling和dropout层。我想将它们的输出连接起来,进行编译和拟合,如下图所示:
我在连接,合并和拟合上感到困惑。我的python代码如下:
out1 = Flatten()(model1)
out2 = Flatten()(model2)
out3 = Flatten()(model3)
out4 = Flatten()(model4)
out5 = Flatten()(model5)
out6 = Flatten()(model6)
out7 = Flatten()(model7)
out8 = Flatten()(model8)
merge = Concatenate([out1, out2, out3, out4, out5, out6, out7, out8])
final_out = Dense(classes, activation='softmax')(merge)
final_model = Model([out1, out2, out3, out4, out5, out6, out7, out8], final_out)
final_model.compile(loss="categorical_crossentr", optimizer= opt, metrics=["accuracy"])
final_model.fit_generator(aug.flow(trainX, trainY, batch_size=BS),validation_data=(testX, testY),
steps_per_epoch=len(trainX) // BS, epochs=EPOCHS, verbose=1)
运行程序时,出现以下错误:
Layer dense_1 was called with an input that isn't a symbolic tensor
出什么问题了?如何连接,编译和训练?谁能帮助我,任何信息都将对您有帮助。