I need to compute the gradient of the network output (not the loss) with respect to the input but I'm getting the error grad can be implicitly created only for scalar outputs
. I'm trying to reproduce what's described in this paper and I need the gradient I mentioned to perform step 7
This is what I'd like to do:
out = netD(input).view(-1)
out.backward(retain_graph=True)
grad = input.grad