peal.generators.interfaces.InvertibleGenerator

class peal.generators.interfaces.InvertibleGenerator[source]

Bases: Generator

A generator with an explicit, invertible latent space.

Adds encode/decode and a prior (sample_z, log_prob_z) to Generator; the diffusion autoencoders, the VAEs and the RAE pipeline are all of this kind. Counterfactual methods such as DiDAE need this level because they perturb a latent code and decode the result. sample_x and log_prob_x are already implemented in terms of the latent operations, so a subclass only supplies the four abstract methods.

Notes

The optional t, stochastic and num_steps arguments of encode/decode are the diffusion controls (how far to noise, whether to use the stochastic sampler, how many sampler steps); non-diffusion subclasses ignore them.

Methods

decode

This function decodes a batch of latent vectors to data samples :param z: A batch of latent vectors

encode

This function encodes a batch of data samples to latent vectors :param x: A batch of data samples

log_prob_x

This function computes the log probability of a batch of data samples :param x: A batch of data samples

log_prob_z

This function computes the log probability of a batch of latent vectors :param z: A batch of latent vectors

sample_x

This function samples a batch of data samples from the generator

sample_z

This function samples a batch of latent vectors from the prior If not implemented, it will throw a NotImplementedError.

abstract encode(x, t=1.0, stochastic=None, num_steps=None)[source]

This function encodes a batch of data samples to latent vectors :param x: A batch of data samples

Returns:

A batch of latent vectors

If not implemented, it will throw a NotImplementedError.

abstract decode(z, t=1.0, stochastic=None, num_steps=None)[source]

This function decodes a batch of latent vectors to data samples :param z: A batch of latent vectors

Returns:

A batch of data samples

If not implemented, it will throw a NotImplementedError.

sample_z(batch_size=1)[source]

This function samples a batch of latent vectors from the prior If not implemented, it will throw a NotImplementedError.

log_prob_z(z)[source]

This function computes the log probability of a batch of latent vectors :param z: A batch of latent vectors

Returns:

The log probability of the batch of latent vectors

If not implemented, it will throw a NotImplementedError.

sample_x(batch_size=1)[source]

This function samples a batch of data samples from the generator

log_prob_x(x)[source]

This function computes the log probability of a batch of data samples :param x: A batch of data samples

Returns:

The log probability of the batch of data samples