Hi Vishay!



 Vishay_Raina:

how is
loss = loss_y_1 + loss_y_2
loss.backward()
different than
loss_y_1.backward()
loss_y_2.backward()


In the first case you backpropagate through the network once; in the
second, twice.  Backpropagating once saves on computation, and these
savings can be significant.
Also, if you want to use the second approach where you backpropagate
twice, you will have to monkey around with setting retain_graph=True.
I can’t think of a use case where I would prefer the second approach.
Best.
K. Frank