Arjun_Gupta:

I am unsure how the addition of my loss_contrastive is discouraging the network from optimizing the original, main loss . Do you have any idea why this might be the case, or what I can do to combat this?


This is pure speculation, but I think that in your use case where both losses are used, the gradients of loss_contrastive might not yield a proper signal and in fact your model mainly optimizes for the loss.
This might happen, if the gradient magnitude is different, so that the gradients of loss_contrastive could be seen as noise compared to the gradients of loss.
If that’s the case, the optimization might lower one loss and unfortunately increase the other one.
You could try to use different weightings on the losses directly to create an equal range of their values and rerun the code again.



 Arjun_Gupta:

Thanks once again for your help; You have helped me numerous times in the past as well and it always stuns me to see how people of your calibre are so generous and accessible even to beginners. I truly appreciate all your effort.


Thanks for the kind words and I’m glad I could help.