I want to correct the gradient for a custom layer using the Taylor expansion:
f'(x+delta) = f'(x) + 1/2*f''(x)*delta
where x is the original output of the layer and f’(x) the default, unmodified gradient, for simplicity this example is the univariate case and delta is something I calculate (it’s the secret sauce for the research idea, so I can’t really go too much into detail what it’s doing).
So I need to access the hessian (not inverse hessian) during for the custom gradient in my nn.module. I have never worked with Hessians and wonder what my options with PyTorch are. Can the autograd framework just compute it for me?