Hi all,
I have read all the other threads on the subject but I do not get what I am doing wrong. I have just started using pytorch so I am probably doing something stupid. I have a trained VGG19 on CIFAR10 (without the softmax) let us call it  net. Then I have my input normalized_input which is simply the first image of the test dataset plus the batch size of one. Now I would like to compute the gradient of the output w.r.t. the input. Right now I am doing this
net.zero_grad()
output = softmax(net(normalized_input), dim=1)
for i in range(10):
    output[0, i].backward(retain_graph=True)
print("GRADIENT")
print(normalized_input.grad)

But I am getting None as an output and it is not clear to me why.