编译模型
model.compile(loss="mse", loss_weights=[0.9, 0.1], optimizer=keras.optimizers.SGD(lr=1e-3))
history = model.fit((x_train_A, x_train_B), (y_train, y_train), epochs=10,
validation_data=((x_valid_A, x_valid_B), (y_valid, y_valid)))
total_loss, main_loss, aux_loss = model.evaluate((x_test_A, x_test_B), (y_test, y_test))
y_pred_main, y_pred_aux = model.predict((x_new_A, x_new_B))
最后一行报错:
<块引用>ValueError: 层dense_4 的输入0 与层不兼容:输入形状的预期轴-1 具有值6,但接收到形状为(None, 8) 的输入
答案 0 :(得分:0)
x_new_B 的形状有误,修正:
x_new_A, x_new_B = x_test_A[:3], x_test_B[:3]