Hi,
If you use the functions in torch.autograd.functional to do this, then you will get a hessian of size input_size + input_size. So in your case 1x1x28x28x1x1x28x28. But you can use .view() to make that 784x784 if that’s what you want. You just collapse the dimensions as if you were using a function with input size 784.