我在keras中使用多输出模型
model1 = Model(input=x, output=[y2,y3])
model1.compile((optimizer='sgd', loss=cutom_loss_function)
Run Code Online (Sandbox Code Playgroud)
我custom_loss_function的;
def custom_loss(y_true, y_pred):
y2_pred = y_pred[0]
y2_true = y_true[0]
loss = K.mean(K.square(y2_true - y2_pred), axis=-1)
return loss
Run Code Online (Sandbox Code Playgroud)
我只想在输出上训练网络y2.
当使用多个输出时,损失函数中的参数y_pred和y_true参数的形状/结构是什么?我可以按上述方式访问它们吗?难道y_pred[0]还是y_pred[:,0]?