I imported hessian from PyHessian library.
Without this two lines, hessian_comp = hessian(net2_u, loss, data= (inputs, targets), cuda=True)
top_eigenvalues, top_eigenvector = hessian_comp.eigenvalues(), my code works very well but when i want to calculate hessian matrix and add hessian line it gives the error i mentioned.
I tried torch.autograd.functional.hessian a few weeks ago but i can remember that i got error for this one too.