Hi, how can I replace the loss value of the loss with another value?
Let’s say I have computed the loss as loss = criterion(outputs, labels). The print(loss.item()) gives me a value of let’s say 2 which I want to replace with let’s say 5. How can I do that?
I tried the following:
loss = criterion(outputs, labels)
print(loss)
loss_value = 5
loss.set_(torch.Tensor([loss_value]).to(device)[0])
print(loss)

but in this case, the grad_function gets disabled. Following is the output of the loss function before and after the new loss value:
tensor(2., device='cuda:0', grad_fn=<NllLossBackward>)
tensor(5., device='cuda:0', grad_fn=<NotImplemented>)