NVPFlow¶
- class viabel.NVPFlow(layers_t, layers_s, mask, prior, prior_param, dim, activation=<function primitive.<locals>.f_wrapped>, seed=1, mc_samples=10000)[source]¶
- Attributes:
dimDimension of the space the distribution is defined on
supports_entropyWhether the approximation family supports closed-form entropy computation.
supports_klWhether the approximation family supports closed-form KL divergence computation.
var_param_dimDimension of the variational parameter
Methods
entropy(var_param)Compute entropy of variational distribution.
f(var_param, x)Forward NVP flow.
g(var_param, z)Inverse NVP flow.
init_param()A variational parameter to use for initialization.
kl(var_param0, var_param1)Compute the Kullback-Leibler (KL) divergence.
log_density(var_param, x)The log density of the variational distribution.
mean_and_cov(var_param)The mean and covariance of the variational distribution.
pth_moment(var_param, p)The absolute pth moment of the variational distribution.
sample(var_param, n_samples[, seed])Generate samples from the variational distribution
Whether analytically computing the pth moment is supported
- __init__(layers_t, layers_s, mask, prior, prior_param, dim, activation=<function primitive.<locals>.f_wrapped>, seed=1, mc_samples=10000)[source]¶
- Parameters:
- layers_tlist of int
The hidden layers dimensions for the translation operator.
- layers_slist of int
The hidden layers dimensions for the scaling operator.
- maskmask int
Mask to apply to the entry of each operator.
- priorApproximationFamily
Prior for the latent space Z.
- prior_paramnumpy array
Parameter vector for the prior, must follow the same format as any variational family.
- dimint
Input dimension.
- seedint
Random seed for reproducibility.
- mc_samplesint
Number of samples to draw internally for computing mean and cov.
- f(var_param, x)[source]¶
Forward NVP flow.
- Parameters:
- var_paramnumpy array
Flat array of variational parameters.
- xnumpy array
Original space data.
- g(var_param, z)[source]¶
Inverse NVP flow.
- Parameters:
- var_paramnumpy array
Flat array of variational parameters.
- znumpy array
Latent space sample.
- log_density(var_param, x)[source]¶
The log density of the variational distribution.
- Parameters:
- var_paramnumpy.ndarray, shape (var_param_dim,)
The variational parameter.
- xnumpy.ndarray, shape (dim,)
Value at which to evaluate the density.
- mean_and_cov(var_param)[source]¶
The mean and covariance of the variational distribution.
- Parameters:
- var_paramnumpy.ndarray, shape (var_param_dim,)
The variational parameter.