Is there a way to print which tensors are passed into .backward()? The problem is that, when I execute loss.backward()
, the code prints out RuntimeError: grad can be implicitly created only for scalar outputs
, meaning that the dimension of tensor passed into .backward() is not the same as the dimension of the tensor whose gradient is being calculated. Because of this, I would like to print which are the tensors used as input of the backward()
function. Is this possible?
can you post your code,it helps us what exactly is wrong