g_vbll

probly.method.g_vbll(base: Predictor[In, Out], prior_scale: float = 1.0, noise_init: float = 1.0, wishart_scale: float = 1.0, dof: float = 1.0) GVBLLPredictor[In, Out][source]

Wrap a model with a Generative Variational Bayesian Last Layer (G-VBLL).

Replaces the model’s last nn.Linear with a GVBLLLayer that models a per-class Gaussian density in feature space based on [HWS24]. A trailing softmax (if any) is removed, since the layer outputs class-conditional log-densities (logits).

The returned predictor’s predict() yields a deterministic CategoricalDistribution. Because each class density decays quadratically away from its mean, the predictive is distance-aware – a useful property for out-of-distribution detection. The layer is fit with the generative ELBO exposed by probly.train.vbll.torch.g_vbll_loss().

Parameters:
  • base – The model to wrap.

  • prior_scale – Scale of the isotropic Gaussian prior on the class means. Defaults to 1.0.

  • noise_init – Median of the random initial shared feature-noise standard deviation. The default of 1.0 matches the reference initialization.

  • wishart_scale – Scale of the Wishart prior on the noise precision. Defaults to 1.0.

  • dof – Degrees of freedom of the Wishart prior on the noise precision. Defaults to 1.0.

Returns:

A GVBLLPredictor whose predict(...) returns a CategoricalDistribution over the classes.

Examples using probly.method.g_vbll

Generative Variational Bayesian Last Layers on Two Moons

Generative Variational Bayesian Last Layers on Two Moons

G-VBLL on MNIST

G-VBLL on MNIST