2 loss functions combination

Hi i’m trying to train a SSD-model
For that i define 2 loss functions,
One for location loss and another for class loss(cross entropy loss)

loss1 = SSD_box_loss(labels_for_batch, gt_with_max_overlap, boxPrediction.cuda())
loss2 = SSD_cls_loss(labels_for_batch, positive_predicted_Boxes, negative_predicted_Boxes, labelPrediction.cuda())
loss = loss1 * loss2

and for optimizer im using

optimizer = torch.optim.Adam(model.parameters(), lr=0.005)

but the loss never decrease,
if i try with only one loss, each losses decreased…
how can i deal with it?

Hi Philipp!

The conventional approach would be to sum the two losses:

loss = loss1 + loss2

It’s hard to know exactly what is going on without knowing what
SSD_box_loss() and SSD_cls_loss() are, but try summing the
losses and see if that fixes your problem.


K. Frank