I have multiple losses: Say lossA, lossB
I have an option to configure which losses to pick for training.
My code for getting total loss is:
lossA = 0
lossB = 0
lossA = getLossA(input, output)
lossB = getLossB(input, output)
totalLoss = lossA + lossB
//optimiser related step
totalLoss might not always be a variable, if both losses are disabled (which won’t generally happen). But for safe keeping, what should be the best method to combine these losses?
Is total = Variable(lossA +lossB, requires_grad=True) okay?
Is it okay to do backward on total loss?