Hi everyone,

I’m currently working on implementing a custom loss function for my project. The idea is to add a loss function with a set of existing ones. Specifically, I’m introducing a novel component calculated as a weight * MSE between two maps obtained online during training.

However, I’ve encountered an issue where adjusting the weight of this new loss term doesn’t seem to have any impact on the final loss and accuracy of my model. Even when I set the weight to 1 or a significantly larger value, the results remain unchanged.

More precisely, even when the seeds are fixed, we can see a contribution from the added loss (weight*MSE) in the result. The problem appears to be centered around the weight itself, which seems to have no influence on the outcome.

The code follows this reasoning:

```
loss = a * loss1 + b * loss2 + c * loss3 + d * loss4
#where d * loss4 is the custom implementation added by us
loss1 = nn.CrossEntropyLoss()
loss2 = nn.KLDivLoss()
loss3 = nn.MSE()
loss4 = nn.MSE()
```

the types are the following:

loss: tensor([value], device=‘cuda:0’, grad_fn=)

loss1: tensor(value, device=‘cuda:0’, grad_fn=)

loss2: tensor(value, device=‘cuda:0’, grad_fn=)

loss3: tensor(value, device=‘cuda:0’, grad_fn=)

loss4: tensor(value4, device=‘cuda:0’, grad_fn=)

a,b,c,d types are: <class: ‘float’>

and the loss4 implementation has this structure:

loss4 = criterion(torch.tensor(factor1, requires_grad=True).cuda(0, non_blocking=True), torch.tensor(factor2, requires_grad=True).cuda(0, non_blocking=True))

Do you have any advice on how to proceed?

Thanks in advance