Approximate distributions
When constructing a PosteriorEstimator, one must choose a family of distributions
Distributions
NeuralEstimators.ApproximateDistribution Type
ApproximateDistributionAn abstract supertype for approximate posterior distributions used in conjunction with a PosteriorEstimator.
Subtypes A <: ApproximateDistribution must implement the following methods:
logdensity(q::A, θ::AbstractMatrix, t::AbstractMatrix)Used during training and therefore must support automatic differentiation.
θis ad × Kmatrix of parameter vectors.tis adstar × Kmatrix of learned summary statistics obtained by applying the neural network in thePosteriorEstimatorto a collection ofKdata sets.Should return a
1 × Kmatrix, where each entry is the log densitylog q(θₖ | tₖ)for thek-th data set evaluated at thek-th parameter vectorθ[:, k].
sampleposterior(q::A, t::AbstractMatrix, N::Integer)Used during inference and therefore does not need to be differentiable.
Should return a
Vectorof lengthK, where each element is ad × Nmatrix containingNsamples from the approximate posteriorq(θ | tₖ)for thek-th data set.
NeuralEstimators.GaussianMixture Type
GaussianMixture <: ApproximateDistribution
GaussianMixture(d::Integer, dstar::Integer; num_components::Integer = 10, kwargs...)A mixture of Gaussian distributions for amortised posterior inference, where d is the dimension of the parameter vector.
The density of the distribution is:
where the parameters
When using a GaussianMixture as the approximate distribution of a PosteriorEstimator, the neural network should be a mapping from the sample space to
Keyword arguments
num_components::Integer = 10: number of components in the mixture.kwargs: additional keyword arguments passed toMLP.
NeuralEstimators.NormalisingFlow Type
NormalisingFlow <: ApproximateDistribution
NormalisingFlow(d::Integer, dstar::Integer; num_coupling_layers::Integer = 6, kwargs...)A normalising flow for amortised posterior inference (e.g., Ardizzone et al., 2019; Radev et al., 2022), where d is the dimension of the parameter vector and dstar is the dimension of the summary statistics for the data.
Normalising flows are diffeomorphisms (i.e., invertible, differentiable transformations with differentiable inverses) that map a simple base distribution (e.g., standard Gaussian) to a more complex target distribution (e.g., the posterior). They achieve this by applying a sequence of learned transformations, the forms of which are chosen to be invertible and allow for tractable density computation via the change of variables formula. This allows for efficient density evaluation during the training stage, and efficient sampling during the inference stage. For further details, see the reviews by Kobyzev et al. (2020) and Papamakarios (2021).
NormalisingFlow uses affine coupling blocks (see AffineCouplingBlock), with activation normalisation (Kingma and Dhariwal, 2018) and permutations used between each block. The base distribution is taken to be a standard multivariate Gaussian distribution.
When using a NormalisingFlow as the approximate distribution of a PosteriorEstimator, the neural network should be a mapping from the sample space to AffineCouplingBlock).
Keyword arguments
num_coupling_layers::Integer = 6: number of coupling layers.kwargs: additional keyword arguments passed toAffineCouplingBlock.
Methods
NeuralEstimators.numdistributionalparams Function
numdistributionalparams(q::ApproximateDistribution)
numdistributionalparams(estimator::PosteriorEstimator)The number of distributional parameters (i.e., the dimension of the space
Building blocks
NeuralEstimators.AffineCouplingBlock Type
AffineCouplingBlock(κ₁::MLP, κ₂::MLP)
AffineCouplingBlock(d₁::Integer, dstar::Integer, d₂; kwargs...)An affine coupling block used in a NormalisingFlow.
An affine coupling block splits its input
where PosteriorEstimator).
To prevent numerical overflows and stabilise the training of the model, the scaling factors
where
Additional keyword arguments kwargs are passed to the MLP constructor when creating κ₁ and κ₂.