Solved by AlphaBetaGamma96 in post #7 
              
              
                I think this should give the correct results, althought you could check this with doing the Jacobian call twice and checking with torch.autograd.functional.Hessian (although Hessian doesn’t have batch-support, so you’d have to apply it iteratively) 

Applying the exp of a log value can aid the stab…