# Is there a Continuous Conditional Variational Autoencoder?

Conditional Variational Autoencoders (CVAE) are an extension of Variational Autoencoder (VAE). In VAEs we have no control on the data generation process, something problematic if we want to generate some specific data. Say, in MNIST, generate instances of 6.

The question is, so far I have only been able to find CVAEs that can condition to discrete features (classes). Is there a CVAE that allows us to condition to continuous variables, kind of a stochastic predictive model?

Yes. CVAEs, as introduced in Sohn, et al (2015), make no assumptions on the conditioning variable.

Letting $$\mathbf{x}$$ denote the conditioning/input variable, $$\mathbf{y}$$ the output variable, and $$\mathbf{z}$$ the latent variable, a CVAE consists of three components:

1. the prior $$p_\theta(\mathbf{z} \mid \mathbf{x})$$, which generates the latent variable $$\mathbf{z}$$ using only the input $$\mathbf{x}$$ and the parameters $$\theta$$,
2. the encoder (the estimated posterior) $$q_\theta(\mathbf{z} \mid \mathbf{x}, \mathbf{y})$$, which generates $$\mathbf{z}$$ using the input, parameters, and output $$\mathbf{y}$$, and
3. the decoder $$p_\theta(\mathbf{y} \mid \mathbf{x}, \mathbf{z})$$, which generates the output variable $$\mathbf{y}$$ using the input and latent variables and the parameters.

Finding the model parameters $$\theta$$ amounts to maximizing the evidence lower bound (ELBO):

$$\operatorname{ELBO}(\theta) = \mathbb{E}_{\mathbf{z} \sim q_\theta(\mathbf{z} \mid \mathbf{x}, \mathbf{y})} \left[\log p_\theta(\mathbf{y} \mid \mathbf{x}, \mathbf{z})\right] - \operatorname{KL}\left(q_\theta(\mathbf{z} \mid \mathbf{x}, \mathbf{y}) \,\middle\|\, p_\theta(\mathbf{z} \mid \mathbf{y})\right).$$

As you can see, nothing so far depends on the input variable $$\mathbf{x}$$ being discrete.

In fact, Dupont (2018) proposes a slightly differently formulated model and gives explicit examples with continuous conditioning variables.