Keras: Sample loss weights with multiple losses

Created on 11 Feb 2017  路  1Comment  路  Source: keras-team/keras

I have a Keras model with 2 losses. For all even observations I want to make use of both losses, whereas for all odd observations I want to use only the 1st loss. The sample_weight parameter in model.fit() seems to only allow me to multiply the loss contribution across all losses with a single scalar for each observation. How do I make all the odd observations not make use of the 2nd loss?

stale

Most helpful comment

Hello,

Have you tried the natural thing of passing it an array of sample_weights (sample_weights=[samp_weight_loss1,samp_weight_loss2] ) ?
If I remember correctly it should work
I gave a quick look to the code and it probably should work :
https://github.com/fchollet/keras/blob/1f5455e29efa4579eebbf894e97ee53cd1257529/keras/engine/training.py#L624

>All comments

Hello,

Have you tried the natural thing of passing it an array of sample_weights (sample_weights=[samp_weight_loss1,samp_weight_loss2] ) ?
If I remember correctly it should work
I gave a quick look to the code and it probably should work :
https://github.com/fchollet/keras/blob/1f5455e29efa4579eebbf894e97ee53cd1257529/keras/engine/training.py#L624

Was this page helpful?
0 / 5 - 0 ratings