NeuralNet¶
- class viabel.NeuralNet(layers_shapes, nonlinearity=<function primitive.<locals>.f_wrapped>, last=<function primitive.<locals>.f_wrapped>, mc_samples=10000, seed=1)[source]¶
- Attributes:
dim
Dimension of the space the distribution is defined on
supports_entropy
Whether the approximation family supports closed-form entropy computation.
supports_kl
Whether the approximation family supports closed-form KL divergence computation.
var_param_dim
Dimension of the variational parameter
Methods
entropy
(var_param)Compute entropy of variational distribution.
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)Generate samples from the variational distribution
Whether analytically computing the pth moment is supported
forward
- __init__(layers_shapes, nonlinearity=<function primitive.<locals>.f_wrapped>, last=<function primitive.<locals>.f_wrapped>, mc_samples=10000, seed=1)[source]¶
- Parameters:
- layers_shapeslist of int
The hidden layers dimensions.
- nonlinearityfunction
Non linear function to apply after each layer except the last layer.
- lastfunction
Non linear function to apply after the last layer.
- mc_samplesint
Number of samples to draw internally for computing mean and cov.
- seedint
Internal seed representation.
- 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.