Module providing Consciousness Exploration Tools for PyTorch.
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the gallery for the big picture.
-
class
consciousnet.models.gmvae.VAEGMP(input_dim, latent_dim, n_mix_components=1, dense_hidden_dims=None, sigma_min=0.001, raw_sigma_bias=0.25, gen_bias_init=0, dropout=0, encoder=None, decoder=None, random_seed=None)[source]¶ Implementation of a Variational Autoencoder (VAE) with Gaussian Mixture Prior (GMP).
-
__init__(input_dim, latent_dim, n_mix_components=1, dense_hidden_dims=None, sigma_min=0.001, raw_sigma_bias=0.25, gen_bias_init=0, dropout=0, encoder=None, decoder=None, random_seed=None)[source]¶ Init class.
- Parameters
input_dim : int
the input size.
latent_dim : int,
the size of the stochastic latent state of the GMVAE.
n_mix_components : int, default 1
the number of components in the mixture prior. If 1, a classical VAE is generated with prior z ~ N(0, 1).
dense_hidden_dims : list of int, default None
the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.
sigma_min : float, default 0.001
the minimum value that the standard deviation of the distribution over the latent state can take.
raw_sigma_bias : float, default 0.25
a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.
gen_bias_init : float, default 0
a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.
dropout : float, default 0
define the dropout rate.
encoder : @callable, default None
a distribution that implements inference q(z | x).
decoder : @callable, default None
a distribution that implements p(x | z). Must accept as arguments the latent state z and return a distribution that can be used to evaluate the log_prob of the targets.
random_seed : int, default None
the seed for the random operations.
-
decoder(z)[source]¶ Computes the generative distribution p(x | z).
- Parameters
z : torch.Tensor (batch_size, latent_size)
the stochastic latent state z.
- Returns
p(x | z) : @callable
the distribution p(x | z) with shape (batch_size, data_size).
-
encoder(x)[source]¶ Computes the inference distribution q(z | x).
- Parameters
x : torch.Tensor (batch_size, data_size)
the input data.
- Returns
q(z | x) : @callable
the distribution q(z | x) with shape (batch_size, latent_size).
-
generate_sample_data(z=None, num_samples=1)[source]¶ Generates mean sample data from the model.
Can provide latent variable ‘z’ to generate data for this point in the latent space, else draw from prior.
- Parameters
z : torch.Tensor (num_samples, latent_size)
the stochastic latent state z.
- Returns
recon : torch.Tensor (batch_size, data_size)
the reconstructed mean samples data.
-
generate_samples(num_samples)[source]¶ Generate ‘num_samples’ samples from the model prior.
- Parameters
num_samples : int
number of samples to draw from the prior distribution.
- Returns
z : Tensor (num_samples, latent_size)
representing samples drawn from the prior distribution.
-
prior()[source]¶ Get the prior distribution p(z).
- Returns
p(z) : @callable
the distribution p(z) with shape (batch_size, latent_size).
-
Follow us