Hi,
I have the following data
input: torch.Size([10000, 1, 28, 28])
output: torch.Size([10000, 10])
The input is from the MNIST data set and the output is the tensor consisting of the output from the classification of all this MNIST data.
I cannot figure out how to calculate the Jacobian for each of these outputs wrt to the input that created the output.
So the Jacobian of the first output in the output tensor would need to be calculated with respect to the first input image. Second Jacobian of the second output with respect to the second input image, and so on.
I can easily do this by looping over the whole data structure, but I am unsure if this is possible in one go with the backward method. But I’d rather not have to do this in raw Python code if the backward method is capable of accommodating this.