Hello all, I have a requirement where I need to get an element wise loss in a batch of data and my model returns loss in training mode. What is the best way to obtain this?
I am doing the following way.
loss0 = model(batch[0])
loss1 = model(batch[1])
loss2 = model(batch[2])
loss3 = model(batch[3])
loss = w0loss0 + w1loss1 + w2loss2 + w3loss3
loss.backward()
my code executes perfectly alright without errors. Am I missing anything here or I am doing right in getting the weighted loss function with different weight to the loss corresponding to the each element of batch? Please suggest.