keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
62.19k stars 19.49k forks source link

Computed loss for multiple outputs #1510

Closed alex-pardo closed 7 years ago

alex-pardo commented 8 years ago

I'm using a siamese network with three different outputs. Two of them are the classification and the other is an additional label I use.

The question is, how the loss given in the callback is computed? I'm sure it is not the sum since I have computed it and does not match, but it is a bit messy to follow the logic in the code. The three outputs are using MAE as the optimizer.

Moreover, It would be nice to be able to monitor each of the loss values in the callback.

alex-pardo commented 8 years ago

I see from the code that keras is performing a weighted sum over each loss, however, which are the weights? Losses are not simply added as you can see in the following image. class_out1 and class_out2 are the outputs of each part of the siamese and output2 is the combination of both (merge_mode='sum'), finally comp. loss is the value obtained when calling test_on_batch. Any clue on how this loss is computed?

screen shot 2016-01-21 at 12 06 21 pm

tboquet commented 8 years ago

Do you use the Graph api? If so the loss is the sum of your outputs' losses. Could you share a simplified version of your code so it will be easier to answer?

ylqfp commented 8 years ago

Also my problem