natural_posterior_network

probly.transformation.natural_posterior_network.natural_posterior_network(encoder: Predictor[In, Out], latent_dim: int, num_classes: int, num_flows: int = 8, certainty_budget: CertaintyBudget = 'normal', alpha_prior: float = 1.0) → NaturalPosteriorNetworkPredictor[In, Out][source]

Create a Natural Posterior Network predictor based on [CBZugner+22].

Computes a Bayesian posterior update over a Dirichlet distribution per sample. The encoder is projected to a low-dim latent z; a single shared normalizing flow yields log p(z); a small linear classifier on the latent yields class log-probabilities log chi(x). The Dirichlet parameters are returned as alpha = alpha_prior + n(x) * chi(x), where n(x) is the budget-scaled, clamped exponential of log p(z).

Parameters:
  • encoder – The base encoder predictor mapping inputs to a latent embedding of shape (B, encoder_dim).

  • latent_dim – Dimension H of the latent space produced by the encoder.

  • num_classes – Number of output classes K.

  • num_flows – Number of radial flow layers in the shared normalizing flow.

  • certainty_budget – Named scheme for scaling log p(z) before exponentiation. One of "constant", "exp-half", "exp", or "normal". Defaults to "normal".

  • alpha_prior – Per-class Dirichlet prior concentration, uniform across classes. Defaults to 1.0.

Returns:

A NaturalPosteriorNetworkPredictor wrapping the encoder with a normalizing-flow density head and a Dirichlet evidence layer.

Examples using probly.transformation.natural_posterior_network.natural_posterior_network

Natural Posterior Network on Two Moons

Natural Posterior Network on Two Moons

Natural Posterior Network on MNIST

Natural Posterior Network on MNIST