normal-computing / posteriors

Uncertainty quantification with PyTorch
https://normal-computing.github.io/posteriors/
Apache License 2.0
282 stars 12 forks source link

Add dense Hessian Laplace #99

Open SamDuffield opened 1 month ago

SamDuffield commented 1 month ago

Might be worth adding a laplace.dense_hessian method since the Hessian is easy to compute with torch.func.hessian.

The main problem with this is that the Hessian is not guaranteed to be positive semidefinite, however there may be cases where it is i.e. when we are sure we have optimized exactly to the MAP or simple models. We should add an epsilon parameter though that adds a nugget epsilon * torch.eye(dim) to the total Hessian that will ensure positive definiteness for epilson large enough.

I think we should should not add a laplace.diag_hessian method since it is not easy to compute in contrast to the Fisher methods.