About training a Faster RCNN with my loss functions

I want to train Faster RCNN with my loss function. I want to use RPN loss for training RPN Network and train ROI head and Classifier head with my loss functions. So, I have three loss functions here and, I want to train my network with these three losses simultaneously. How can I do this? is there a method in Pytorch for training ??

You could calculate the losses separately, accumulate them, and call backward on the final loss to calculate the gradients. Something like this would work:

loss1 = criterion1(output1, target1)
loss2 = criterion2(output2, target2)
loss3 = criterion3(output3, target3)
loss = loss1 + loss2 + loss3
loss.backward()
1 Like