I am using a multiple output model in Keras
model1 = Model(input=x, output=[y2, y3])
model1.compile((optimizer='sgd', loss=cutom_loss_function)
my custom_loss
function is
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
I only want to train the network on output y2
.
What is the shape/structure of the y_pred
and y_true
argument in loss function when multiple outputs are used?
Can I access them as above? Is it y_pred[0]
or y_pred[:,0]
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…