aleximmer / Laplace

Laplace approximations for Deep Learning.
https://aleximmer.github.io/Laplace
MIT License
458 stars 71 forks source link

BCEWithLogitsLoss (Binary) Classification Support? #107

Closed dan-sprague closed 2 years ago

dan-sprague commented 2 years ago

Hi,

I have a binary classifier that I am trying to get a last-layer posterior approximation of. The model is trained with BCELossWithLogits, and therefore outputs scalar logits rather than a tensor of length 2.

I have been unable to get la.fit to work with this setup. Changing to a CrossEntropyLoss with 2 classes allows it to work, but the model is large and cumbersome to retrain.

wiseodd commented 2 years ago

Unfortunately, it's not supported yet because the Hessian-computation libraries we use (BackPACK and ASDL) do not support BCE yet. Once they've added support to BCE loss, it'll be easy to add it to laplace-torch.