How to calculate HVP in neural networks

What is the recommended way of calculating the Hessian vector product of a neural network function? Torch.func seems to provide the related functions, but I’m not sure how to pass in the vector.

Hi @ksnxr,

There’s an example within the documentation here: Jacobians, Hessians, hvp, vhp, and more: composing function transforms — PyTorch Tutorials 2.0.1+cu117 documentation

If you have a minimal reproducible example, please do share it.