← Writing

Adversarial Training for Generative Models

Paper info

Title: Generative Adversarial Nets

Authors: Ian J. Goodfellow et al.

TL;DR

The paper addresses the fundamental problem in training Generative Models—the challenge of modeling intractable and high-dimensional probabilistic computations. The authors propose an architecture composed of a generative model and a discriminative model that compete to minimize and maximize the loss simultaneously. If both networks are trained well enough, the generator’s distribution matches the data distribution, so the discriminator cannot tell samples apart. The paper demonstrates the effectiveness of the approach through qualitative and quantitative evaluation.

Context

Machine Learning models can broadly be classified into two classes, namely discriminative and generative. Discriminative models learn to model a decision boundary between classes; thus, they learn the conditional distribution P(Y∣X)P(Y|X). Their use is limited to discriminative classification tasks. Logistic Regression, Decision Trees, and SVMs are examples of discriminative models. Generative models, on the other hand, learn the joint distribution P(X,Y)P(X,Y) of the data and can generate new instances—Naive Bayes and Gaussian Mixture Model are examples of generative models.

Main idea

Generative Adversarial Networks (GANs) are generative models that learn to generate data similar to the training set. They consist of two major components: a generative model and a discriminative model—adversaries competing with each other. A good analogy given in the paper is that the generator can be thought of as a counterfeiter trying to generate fake coins, and the discriminator as a police officer trying to detect counterfeit coins.

The generator produces an output x=G(z)x = G(z), where GG is a differentiable multi-layer perceptron and the input zz is a noise variable sampled from a known distribution such as the standard Gaussian. The aim is to learn a probability distribution pgp_g using G(z;θg)G(z; \theta_g).

The discriminator, D(x;θd)D(x; \theta_d), is the second differentiable multi-layer perceptron that classifies whether the data came from pdatap_{\text{data}} instead of pgp_g. Therefore, the discriminator is trained to maximize log⁡D(x)\log D(x) on real data and log⁡(1−D(G(z)))\log(1 - D(G(z))) on generated samples. The generator is trained to minimize log⁡(1−D(G(z)))\log(1 - D(G(z))).

GAN training dynamics

Figure 1: Discriminator (dashed blue), data distribution (dotted black), and generator distribution (solid green) during adversarial training.

Therefore, this can be formulated as a minimax optimization with a value function V(G,D)V(G, D), where the generator tries to shift its distribution toward the real distribution and the discriminator tries to learn the perfect boundary, as shown in Figure 1.

min⁡Gmax⁡DV(D,G)=Ex∼pdata(x)[log⁡D(x)]+Ez∼pz(z)[log⁡(1−D(G(z)))]\min_G \max_D V(D, G) = \mathbb{E}_{x \sim p_{\text{data}}(x)}[\log D(x)] + \mathbb{E}_{z \sim p_z(z)}[\log(1 - D(G(z)))] D∗(x)=pdata(x)pdata(x)+pg(x)D^*(x) = \frac{p_{\text{data}}(x)}{p_{\text{data}}(x) + p_g(x)}

Substituting the discriminator into the value function yields:

C(G)=Ex∼pdata(x)[log⁡pdata(x)pdata(x)+pg(x)]+Ex∼pg(x)[log⁡pg(x)pdata(x)+pg(x)]C(G) = \mathbb{E}_{x \sim p_{\text{data}}(x)}\left[\log \frac{p_{\text{data}}(x)}{p_{\text{data}}(x) + p_g(x)}\right] + \mathbb{E}_{x \sim p_g(x)}\left[\log \frac{p_g(x)}{p_{\text{data}}(x) + p_g(x)}\right]

After several steps of training, if both distributions overlap perfectly, pdata(x)=pg(x)p_{\text{data}}(x) = p_g(x), D(x)=12D(x) = \frac{1}{2}. At this step, the discriminator is unable to differentiate between a sample from the training and the generated data.

Question

What happens if we have a very strong discriminator?

How do we train a conditional generative model p(x∣c)p(x|c)?