我想在Xception和Inceptionv3模型上进行合奏。我尝试将它们与以下代码集成在一起。但是在模型拟合过程中出现错误。请帮助我解决错误。
先谢谢了。
# Ensemble of Model 1 & Model 2
models = [inceptionv3,xception]
for i in range(len(models)):
model = models[i]
ensemble_visible = [model.input for model in models]
ensemble_outputs = [model.output for model in models]
merge = concatenate(ensemble_outputs)
x = Dense(1024, activation='relu')(merge)
x = Dropout(0.25)(x)
predictions = Dense(7, activation='softmax')(x)
model = Model(inputs = ensemble_visible, outputs = predictions)
model.compile(optimizer='rmsprop',
loss='categorical_crossentropy',
metrics=[categorical_accuracy, top_2_accuracy,
top_3_accuracy])
history = model.fit_generator(train_batches,
steps_per_epoch=train_steps,
class_weight=class_weights,
validation_data=valid_batches,
validation_steps=val_steps,
epochs=5, verbose=1,
callbacks=callbacks_list)
在拟合模型时出现以下错误。
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays: [array([[[[-0.1607843 , -0.36470586, -0.372549 ],
[-0.11372548, -0.35686272, -0.3960784 ],
[-0.15294117, -0.31764704, -0.34117645],
...,
[-0.17647058, -0.34117645,...