lampe.inference.npe¶
Neural posterior estimation (NPE) components.
The principle of neural posterior estimation is to train a parametric conditional distribution \(p_\phi(\theta | x)\) to approximate the posterior distribution \(p(\theta | x)\). The optimization problem is to minimize the expected Kullback-Leibler (KL) divergence between the two distributions for all observations \(x \sim p(x)\), that is,
Normalizing flows are typically used for \(p_\phi(\theta | x)\) as they are differentiable parametric distributions enabling gradient-based optimization techniques.
Wikipedia
https://wikipedia.org/wiki/Kullback-Leibler_divergence
Classes¶
Descriptions¶
- class lampe.inference.npe.NPE(theta_dim, x_dim, build=<class 'zuko.flows.autoregressive.MAF'>, **kwargs)¶
Creates a neural posterior estimation (NPE) normalizing flow.
- Parameters:
theta_dim (int) – The dimensionality \(D\) of the parameter space.
x_dim (int) – The dimensionality \(L\) of the observation space.
build (Callable[[int, int], Flow]) – The flow constructor (e.g.
zuko.flows.spline.NSF). It takes the number of sample and context features as positional arguments.kwargs – Keyword arguments passed to the constructor.
- class lampe.inference.npe.NPELoss(estimator)¶
Creates a module that calculates the negative log-likelihood (NLL) loss for a NPE density estimator.
Given a batch of \(N\) pairs \((\theta_i, x_i)\), the module returns
\[l = \frac{1}{N} \sum_{i = 1}^N -\log p_\phi(\theta_i | x_i) .\]- Parameters:
estimator (Module) – A log-density estimator \(\log p_\phi(\theta | x)\).