# A Brief Survey of Generative Models

## Overview

This page is a high-level summary of various generative models with little explanations. Models to cover are as follows:

Variational Autoencoders (VAE)

• Kingma, Diederik P., and Max Welling. “Auto-encoding variational bayes.” arXiv preprint arXiv:1312.6114 (2013).

Extention to VAE to use non-Gaussian encoders

• Mescheder, Lars, Sebastian Nowozin, and Andreas Geiger. “Adversarial variational bayes: Unifying variational autoencoders and generative adversarial networks.” arXiv preprint arXiv:1701.04722 (2017).

• Goodfellow, Ian, et al. “Generative adversarial nets.” Advances in neural information processing systems. 2014.

Generalized divergence minimization GAN ($f$-GAN)

• Nowozin, Sebastian, Botond Cseke, and Ryota Tomioka. “f-gan: Training generative neural samplers using variational divergence minimization.” Advances in Neural Information Processing Systems. 2016.

Wasserstein GAN (WGAN)

• Arjovsky, Martin, Soumith Chintala, and Léon Bottou. “Wasserstein gan.” arXiv preprint arXiv:1701.07875 (2017).

• Makhzani, Alireza, et al. “Adversarial autoencoders.” arXiv preprint arXiv:1511.05644 (2015).

Wasserstein Auto-Encoder (WAE)

• Tolstikhin, Ilya, et al. “Wasserstein Auto-Encoders.” arXiv preprint arXiv:1711.01558 (2017).

Cramer GAN

• Bellemare, Marc G., et al. “The Cramer Distance as a Solution to Biased Wasserstein Gradients.” arXiv preprint arXiv:1705.10743 (2017).

## VAE

### Model setup:

• Recognition model: $q_\phi(z \vert x) = \mathcal N(\mu=h_1(x), \sigma^2 \mathbf I=h_2(x)\mathbf I)$
• Assumed fixed prior: $p(z) = \mathcal N(0,\mathbf I)$
• Generation model: $p_\theta(x \vert z) = \mathcal N(\mu=g_1(z), \sigma^2 \mathbf I=g_2(z)\mathbf I)$
• Implied (but intractable) posterior: $p_\theta(z\vert x)$

### Optimization objective:

Difficulties in calculating $\mathcal L(\theta, \phi, x^i)$:

• Due to the generality of $q$ and $p$ (typically a neural network), the expectation in $\ref{vae_elbo}$ does not have an analytical form. So we need to resort to Monte Carlo estimation.
• Furthermore, direct sampling $z$ according to $q$ poses difficulty in taking derivative against parameters $\phi$ that parameterizes the distribution $q$.

Solution: Reparameterization Trick

Find smooth and invertible transformation $z=g_\phi(\epsilon)$ such that with $\epsilon$ drawn from a fixed (non-parameterized) distribution $p(\epsilon)$ we have $z \sim q(z; \phi)$, so

For the Normal distribution used here ($q_\phi(z\vert x)$), it is convenient to use location-scale transformation, $z=\mu+\sigma * \epsilon$ with $\epsilon \sim \mathcal N(0,\mathbf I)$.

For total $N$ data points with mini batch size $M$:

For sufficiently large batch size $M$, the inner loop sample size $L$ can be set to 1. Due to stochastic mini batch gradient descent and stochastic expectation estimation, this is also called doubly stochastic estimation.

### Using non-Gaussian encoders

Todo: discuss AVB paper

### Gumble trick for discrete latent variables

Ref for this section:

1. Gumble max trick https://hips.seas.harvard.edu/blog/2013/04/06/the-gumbel-max-trick-for-discrete-distributions/
2. Balog, Matej, et al. “Lost Relatives of the Gumbel Trick.” arXiv preprint arXiv:1706.04161 (2017).
3. Jang, Eric, Shixiang Gu, and Ben Poole. “Categorical reparameterization with gumbel-softmax.” arXiv preprint arXiv:1611.01144 (2016).

Gumble distribution:

## $f$-GAN and GAN

### Prelude on $f$-divergence and its variational lower bound

The f-divergence family

where the generator function $f: \mathbb{R}_{+} \rightarrow \mathbb{R}$ is a convex, lower-semicontinuous function satisfying $f(1) = 0$.

Every convex, lower-semicontinuous function has a convex conjugate function $f^c$, also known as Fenchel conjugate. This function is defined as

Function $f^c$ is again convex and lower-semicontinuous and the pair $(f,f^c)$ is dual to each other, i.e. $\left(f^{c}\right)^c=f$. So we can represent $f$ as

With this we can establish a lower bound for estimating the f-divergence in general

where $\mathcal T$ is an arbitrary class of functions $T: \mathcal X \rightarrow \mathbb R$. The inequality is due to Jessen’s inequality and constraints imposed by $\mathcal T$.

The bond is tight for

Suppose our goal is to come up with a distribution $Q$ (model) that is close to $P$ (the data distribution) and the similarity score (loss) is measured by $D_f(P | Q)$. However the direct calculation of $\ref{f_div}$ is intractable, such as the case where the functional form of $P$ is unknown and $Q$ is a complex model parameterized by a neural network.

To be specific:

• Evaluating $q(x)$ at any $x$ is easy, but integrating it is hard due to lack of easy functional form.
• For $p(x)$, we do not know how to evaluate it at any $x$
• Sampling from both $P$ and $Q$ are easy. Because drawing from data set approximates $x \sim P$ and we can make the model $Q$ take random vectors as input which are easy to produce.

Fortunately, we can sample from both of them easily. In this case, $\ref{f_lowerbound}$ offers a way to estimate the lower bound of the divergence. We would need to maximize this lower bound by changing $T$ so that it is close to the true divergence, then minimize it over $Q$. This is formally stated as follows.

To ensure that the output of $T_\omega$ respects the domain of ${f^c}$, we define $T_\omega(x) = g_f(V_\omega(x))$, where $V_\omega: \mathcal X \rightarrow \mathbb R$ without any range constraints on the output and $g_f: \mathbb R \rightarrow \text{dom}_{f^c}$ is an output activation function specific to the $f$-divergence used with suitable output ranges.

### GAN

For the original GAN, with a divergence target similar to Jensen-Shannon $$$F(\theta, \omega) = \mathbb{E}_{x\sim P}[\log D_\omega(x)] + \mathbb{E}_{x\sim Q_\theta}[\log(1-D_\omega(x))]$$$ with $D_\omega = 1/(1+e^{-V_\omega(x)})$ which corresponds to the following

$g_f(\nu)= \log(1/(1+e^{-\nu}))$ $T_\omega(x) = \log (D_\omega(x)) = g_f(V_\omega(x))$ $f^c(t) = -\log (1-\exp(t))$ $\log (1-D_\omega(x)) = -f^c(T_\omega(x))$

### Practical considerations in adversarial training

Todo: log trick, DCGAN heuristics

Name $D_f(P\vert Q)$ Generator $f(u)$ $T^*(x)$
Forward KL $\int p(x) \log \frac{p(x)}{q(x)} dx$ $u\log u$ $1 +\log \frac{q(x)}{p(x)}$
Reverse KL $\int q(x) \log \frac{p(x)}{q(x)} dx$ $-\log u$ $- \frac{q(x)}{p(x)}$
Jensen-Shannon $\frac{1}{2} \int p(x) \log \frac{2p(x)}{p(x)+q(x)} + q(x) \log \frac{2q(x)}{p(x)+q(x)} dx$ $u\log u - (u+1) \log \frac{u+1}{2}$ $\log \frac{2p(x)}{p(x)+q(x)}$
GAN $\int p(x) \log \frac{2p(x)}{p(x)+q(x)} + q(x) \log \frac{2q(x)}{p(x)+q(x)} dx -\log(4)$ $u\log u - (u+1) \log (u+1)$ $\log \frac{p(x)}{p(x)+q(x)}$
Name Conjugate $f^c(t)$ $\text{dom}_{f^c}$ Output activation $g_f$ $f’(1)$
Forward KL $\exp(t-1)$ $\mathbb R$ $\nu$ $1$
Reverse KL $-1-\log(-t)$ $\mathbb R_{-}$ $-\exp(\nu)$ $-1$
Jensen-Shannon $-\log(2-\exp(t))$ $t < \log(2)$ $\log(2) - \log(1+\exp(-\nu))$ $0$
GAN $-\log(1-\exp(t))$ $\mathbb R_{-}$ $- \log(1+\exp(-\nu))$ $-\log(2)$

## WGAN and WAE

### Optimal transport (OT)

Kantorovich formulated the optimization target in optimal transport problems as follows

where $\mathcal P(X\sim P_X, Y\sim P_Y)$ is a set of all join distributions of $(X,Y)$ with marginals $P_X$ and $P_Y$.

### Wasserstein distance

When $c(x,y) = | x-y | ^p$ for $p \ge 1$, $W_c^{1/p}$ is called p-Wasserstein distance.

The optimization problem is highly intractable in general, due to the constraint. However when $p=1$, Kantorovich-Rubinstein duality holds:

The family of divergences from $f$-divergence only consider the relative probability (the ratio between two probability density functions) and do not measure the closeness of the underlying outcomes. With disjoint support or overlapping support but intersections that yield zero measure, the divergence between a target distribution and a $\theta$-parameterized distribution might not be continuous with respect to $\theta$. Wasserstein distance on the other hand does take into account the underlying topology of the outcomes and is continuous and differentiable almost everywhere with respect to $\theta$ and thus almost always provide useful gradient for optimization.

### Wasserstein GAN (WGAN)

Following the dual form of $W_1$, we can form a generative-adversarial model for a data distribution $P_D$ and model $Q_\theta$ with auxiliary function $f$ that is 1-Lipschitz continuous.

#### Practical considerations for WGAN

Todo: Gradient clipping with K-Lipschitz constraint on $f$; Soft gradient penalty (WGAN-GP)

### Wasserstein Auto-encoder (WAE)

Rather than working with the dual or Wasserstein distance, which only holds for $W_1$, we can also work with the primal form directly. As shown in Tolstikhin, Ilya, et al. “Wasserstein Auto-Encoders.” the following holds when we have a deterministic decoder mapping latent variable $Z$ to $Y$ through $y=G(z)$:

The constraint put on $Q(Z\vert X)$ is that its marginal needs to equal to $P(Z)$. To have a feasible optimization problem we relax this constraint with the following constraint-free optimization target with a penalty that assess the closeness between $Q(Z)$ and $P(Z)$ via any reasonable divergence. This new objective is named penalized optimal transport (POT).

If the divergence between $P_Z$ and $Q_Z$ is intractable to directly calculate, we could use generative-adversarial training to approximate it (see $f$-GAN).

Note: if decoder is probabilistic instead of deterministic, we would only have $W_c(P_X, P_G) \le W_c^\dagger(P_X, P_G)$, so we are minimizing an upper bound of the true OT cost.

Thought: the original paper used JS divergence for $D_Z$, how about we use Wasserstein distance for $D_Z$.

Todo: discuss connections to AAE paper