core.posterior_models.normalizing_flow.NormalizingFlowPosteriorModel

core.posterior_models.normalizing_flow.NormalizingFlowPosteriorModel(**kwargs)

Posterior model based on a (discrete) normalizing flow.

A normalizing flow describes a distribution as a sequence of discrete transformations on a parameter space, ultimately taking samples from the base space (multivariate standard normal) to the desired distribution. The discrete transforms are parametrized functions (e.g., splines), which are designed to be invertible with simple Jacobian determinant. The probability density is given by the change of variables rule,

q(theta | d) = pi(f_d^{-1}(theta)) | det J_{f_d^{-1}} |

where pi = N(0,1)^D is the base space distribution f_d is the normalizing flow on the D-dimensional space

The flow f_d is allowed to depend on context information d, which would be observational data in the case of posterior estimation. By construction, the flow has fast sampling and density evaluation, require just forward passes of the network.

This class uses normalizing flows from the dingo.core.nn.nsf module (which in turn uses glasflow, which is based on nflows). It is intended to construct and hold a neural network for estimating the posterior density, as well as saving / loading, and training. It also calls the sampling and density evaluation routines from the flows.

Methods

Name Description
initialize_network
log_prob
loss
sample
sample_and_log_prob

initialize_network

core.posterior_models.normalizing_flow.NormalizingFlowPosteriorModel.initialize_network(
)

log_prob

core.posterior_models.normalizing_flow.NormalizingFlowPosteriorModel.log_prob(
    theta,
    *context,
)

loss

core.posterior_models.normalizing_flow.NormalizingFlowPosteriorModel.loss(
    theta,
    *context,
)

sample

core.posterior_models.normalizing_flow.NormalizingFlowPosteriorModel.sample(
    *context,
    num_samples=1,
)

sample_and_log_prob

core.posterior_models.normalizing_flow.NormalizingFlowPosteriorModel.sample_and_log_prob(
    *context,
    num_samples=1,
)