jarvico:

I know that backward operation is done based ona scalar value. So when I apply backward method on output tensor , I got error. And, I couldn’t handle this in Pytorch.


The backward operation accepts a gradient argument, so you could pass e.g. torch.ones_like(output) to it.
Would this help in your case?