Very clear explaination!. If I have two losses:loss1 get data from dataloader1 with batch size of 4, while loss2 get data from loader2 with batch size of 4. Then what is batch size of loss=loss1+loss2? Is it 4 or 8? The code likes
optimizer.zero_grad()
loss1=CrossEntropyLoss(output1,target1)
loss2=CrossEntropyLoss(output2,target2)
loss=loss1+loss2
loss.backward()
optimizer.step()