Wasserstein GAN

Last updated

The Wasserstein Generative Adversarial Network (WGAN) is a variant of generative adversarial network (GAN) proposed in 2017 that aims to "improve the stability of learning, get rid of problems like mode collapse, and provide meaningful learning curves useful for debugging and hyperparameter searches". [1] [2]

Contents

Compared with the original GAN discriminator, the Wasserstein GAN discriminator provides a better learning signal to the generator. This allows the training to be more stable when generator is learning distributions in very high dimensional spaces.

Motivation

The GAN game

The original GAN method is based on the GAN game, a zero-sum game with 2 players: generator and discriminator. The game is defined over a probability space , The generator's strategy set is the set of all probability measures on , and the discriminator's strategy set is the set of measurable functions .

The objective of the game is

The generator aims to minimize it, and the discriminator aims to maximize it.

A basic theorem of the GAN game states that

Theorem (the optimal discriminator computes the Jensen–Shannon divergence)  For any fixed generator strategy , let the optimal reply be , then

where the derivative is the Radon–Nikodym derivative, and is the Jensen–Shannon divergence.

Repeat the GAN game many times, each time with the generator moving first, and the discriminator moving second. Each time the generator changes, the discriminator must adapt by approaching the ideal

Since we are really interested in , the discriminator function is by itself rather uninteresting. It merely keeps track of the likelihood ratio between the generator distribution and the reference distribution. At equilibrium, the discriminator is just outputting constantly, having given up trying to perceive any difference. [note 1]

Concretely, in the GAN game, let us fix a generator , and improve the discriminator step-by-step, with being the discriminator at step . Then we (ideally) have

so we see that the discriminator is actually lower-bounding .

Wasserstein distance

Thus, we see that the point of the discriminator is mainly as a critic to provide feedback for the generator, about "how far it is from perfection", where "far" is defined as Jensen–Shannon divergence.

Naturally, this brings the possibility of using a different criteria of farness. There are many possible divergences to choose from, such as the f-divergence family, which would give the f-GAN. [3]

The Wasserstein GAN is obtained by using the Wasserstein metric, which satisfies a "dual representation theorem" that renders it highly efficient to compute:

Theorem (Kantorovich-Rubenstein duality)  When the probability space is a metric space, then

for any fixed ,

where is the Lipschitz norm.

A proof can be found in the main page on Wasserstein metric.

Definition

By the Kantorovich-Rubenstein duality, the definition of Wasserstein GAN is clear:

A Wasserstein GAN game is defined by a probability space , where is a metric space, and a constant .

There are 2 players: generator and discriminator (also called "critic").

The generator's strategy set is the set of all probability measures on .

The discriminator's strategy set is the set of measurable functions of type with bounded Lipschitz-norm: .

The Wasserstein GAN game is a zero-sum game, with objective function

The generator goes first, and the discriminator goes second. The generator aims to minimize the objective, and the discriminator aims to maximize the objective:

By the Kantorovich-Rubenstein duality, for any generator strategy , the optimal reply by the discriminator is , such that

Consequently, if the discriminator is good, the generator would be constantly pushed to minimize , and the optimal strategy for the generator is just , as it should.

Comparison with GAN

In the Wasserstein GAN game, the discriminator provides a better gradient than in the GAN game.

Consider for example a game on the real line where both and are Gaussian. Then the optimal Wasserstein critic and the optimal GAN discriminator are plotted as below:

The optimal Wasserstein critic
D
W
G
A
N
{\displaystyle D_{WGAN}}
and the optimal GAN discriminator
D
{\displaystyle D}
for a fixed reference distribution
m
r
e
f
{\displaystyle \mu _{ref}}
and generator distribution
m
G
{\displaystyle \mu _{G}}
. Both the Wasserstein critic
D
W
G
A
N
{\displaystyle D_{WGAN}}
and the GAN discriminator
D
{\displaystyle D}
are scaled down to fit the plot. Wasserstein-GAN critic vs GAN discriminator.svg
The optimal Wasserstein critic and the optimal GAN discriminator for a fixed reference distribution and generator distribution . Both the Wasserstein critic and the GAN discriminator are scaled down to fit the plot.

For fixed discriminator, the generator needs to minimize the following objectives:

Let be parametrized by , then we can perform stochastic gradient descent by using two unbiased estimators of the gradient:

where we used the reparametrization trick. [note 2]

The same plot, but with the GAN discriminator
D
{\displaystyle D}
replaced by
ln
[?]
(
1
-
D
)
{\displaystyle \ln(1-D)}
(and scaled down to fit the plot) Wasserstein-GAN critic vs log-minus GAN discriminator.svg
The same plot, but with the GAN discriminator replaced by (and scaled down to fit the plot)

As shown, the generator in GAN is motivated to let its "slide down the peak" of . Similarly for the generator in Wasserstein GAN.

For Wasserstein GAN, has gradient 1 almost everywhere, while for GAN, has flat gradient in the middle, and steep gradient elsewhere. As a result, the variance for the estimator in GAN is usually much larger than that in Wasserstein GAN. See also Figure 3 of. [1]

The problem with is much more severe in actual machine learning situations. Consider training a GAN to generate ImageNet, a collection of photos of size 256-by-256. The space of all such photos is , and the distribution of ImageNet pictures, , concentrates on a manifold of much lower dimension in it. Consequently, any generator strategy would almost surely be entirely disjoint from , making . Thus, a good discriminator can almost perfectly distinguish from , as well as any close to . Thus, the gradient , creating no learning signal for the generator.

Detailed theorems can be found in. [4]

Training Wasserstein GANs

Training the generator in Wasserstein GAN is just gradient descent, the same as in GAN (or most deep learning methods), but training the discriminator is different, as the discriminator is now restricted to have bounded Lipschitz norm. There are several methods for this.

Upper-bounding the Lipschitz norm

Let the discriminator function to be implemented by a multilayer perceptron:

where , and is a fixed activation function with . For example, the hyperbolic tangent function satisfies the requirement. Then, for any , let , we have by the chain rule:

Thus, the Lipschitz norm of is upper-bounded by

where is the operator norm of the matrix, that is, the largest singular value of the matrix, that is, the spectral radius of the matrix (these concepts are the same for matrices, but different for general linear operators). Since , we have , and consequently the upper bound:

Thus, if we can upper-bound operator norms of each matrix, we can upper-bound the Lipschitz norm of .

Weight clipping

Since for any matrix , let , we have

by clipping all entries of to within some interval , we have can bound .

This is the weight clipping method, proposed by the original paper. [1]

Spectral normalization

The spectral radius can be efficiently computed by the following algorithm:

INPUT matrix and initial guess

Iterate to convergence . This is the eigenvector of with eigenvalue .

RETURN

By reassigning after each update of the discriminator, we can upper bound , and thus upper bound .

The algorithm can be further accelerated by memoization: At step , store . Then at step , use as the initial guess for the algorithm. Since is very close to , so is close to , so this allows rapid convergence.

This is the spectral normalization method. [5]

Gradient penalty

Instead of strictly bounding , we can simply add a "gradient penalty" term for the discriminator, of form

where is a fixed distribution used to estimate how much the discriminator has violated the Lipschitz norm requirement.

The discriminator, in attempting to minimize the new loss function, would naturally bring close to everywhere, thus making .

This is the gradient penalty method. [6]

Further reading

See also

Related Research Articles

In mathematics, the Lp spaces are function spaces defined using a natural generalization of the p-norm for finite-dimensional vector spaces. They are sometimes called Lebesgue spaces, named after Henri Lebesgue, although according to the Bourbaki group they were first introduced by Frigyes Riesz.

In the mathematical field of real analysis, the monotone convergence theorem is any of a number of related theorems proving the convergence of monotonic sequences that are also bounded. Informally, the theorems state that if a sequence is increasing and bounded above by a supremum, then the sequence will converge to the supremum; in the same way, if a sequence is decreasing and is bounded below by an infimum, it will converge to the infimum.

In mathematical analysis, Hölder's inequality, named after Otto Hölder, is a fundamental inequality between integrals and an indispensable tool for the study of Lp spaces.

In mathematical analysis, the Minkowski inequality establishes that the Lp spaces are normed vector spaces. Let be a measure space, let and let and be elements of Then is in and we have the triangle inequality

In mathematics, Fatou's lemma establishes an inequality relating the Lebesgue integral of the limit inferior of a sequence of functions to the limit inferior of integrals of these functions. The lemma is named after Pierre Fatou.

<span class="mw-page-title-main">Jensen's inequality</span> Theorem of convex functions

In mathematics, Jensen's inequality, named after the Danish mathematician Johan Jensen, relates the value of a convex function of an integral to the integral of the convex function. It was proved by Jensen in 1906, building on an earlier proof of the same inequality for doubly-differentiable functions by Otto Hölder in 1889. Given its generality, the inequality appears in many forms depending on the context, some of which are presented below. In its simplest form the inequality states that the convex transformation of a mean is less than or equal to the mean applied after convex transformation; it is a simple corollary that the opposite is true of concave transformations.

In mathematics, the total variation identifies several slightly different concepts, related to the (local or global) structure of the codomain of a function or a measure. For a real-valued continuous function f, defined on an interval [a, b] ⊂ R, its total variation on the interval of definition is a measure of the one-dimensional arclength of the curve with parametric equation xf(x), for x ∈ [a, b]. Functions whose total variation is finite are called functions of bounded variation.

<span class="mw-page-title-main">Mixing (mathematics)</span> Mathematical description of mixing substances

In mathematics, mixing is an abstract concept originating from physics: the attempt to describe the irreversible thermodynamic process of mixing in the everyday world: e.g. mixing paint, mixing drinks, industrial mixing.

In probability theory and statistics, the generalized extreme value (GEV) distribution is a family of continuous probability distributions developed within extreme value theory to combine the Gumbel, Fréchet and Weibull families also known as type I, II and III extreme value distributions. By the extreme value theorem the GEV distribution is the only possible limit distribution of properly normalized maxima of a sequence of independent and identically distributed random variables. Note that a limit distribution needs to exist, which requires regularity conditions on the tail of the distribution. Despite this, the GEV distribution is often used as an approximation to model the maxima of long (finite) sequences of random variables.

In mathematics, the Wasserstein distance or Kantorovich–Rubinstein metric is a distance function defined between probability distributions on a given metric space . It is named after Leonid Vaseršteĭn.

In mathematics, uniform integrability is an important concept in real analysis, functional analysis and measure theory, and plays a vital role in the theory of martingales.

In mathematics — specifically, in stochastic analysis — the infinitesimal generator of a Feller process is a Fourier multiplier operator that encodes a great deal of information about the process.

In functional analysis, the dual norm is a measure of size for a continuous linear function defined on a normed vector space.

In mathematics, the logarithmic norm is a real-valued functional on operators, and is derived from either an inner product, a vector norm, or its induced operator norm. The logarithmic norm was independently introduced by Germund Dahlquist and Sergei Lozinskiĭ in 1958, for square matrices. It has since been extended to nonlinear operators and unbounded operators as well. The logarithmic norm has a wide range of applications, in particular in matrix theory, differential equations and numerical analysis. In the finite-dimensional setting, it is also referred to as the matrix measure or the Lozinskiĭ measure.

In mathematics, especially measure theory, a set function is a function whose domain is a family of subsets of some given set and that (usually) takes its values in the extended real number line which consists of the real numbers and

In mathematical analysis, Lorentz spaces, introduced by George G. Lorentz in the 1950s, are generalisations of the more familiar spaces.

In probability theory, a McKean–Vlasov process is a stochastic process described by a stochastic differential equation where the coefficients of the diffusion depend on the distribution of the solution itself. The equations are a model for Vlasov equation and were first studied by Henry McKean in 1966. It is an example of propagation of chaos, in that it can be obtained as a limit of a mean-field system of interacting particles: as the number of particles tends to infinity, the interactions between any single particle and the rest of the pool will only depend on the particle itself.

Stochastic portfolio theory (SPT) is a mathematical theory for analyzing stock market structure and portfolio behavior introduced by E. Robert Fernholz in 2002. It is descriptive as opposed to normative, and is consistent with the observed behavior of actual markets. Normative assumptions, which serve as a basis for earlier theories like modern portfolio theory (MPT) and the capital asset pricing model (CAPM), are absent from SPT.

<span class="mw-page-title-main">Generative adversarial network</span> Deep learning method

A generative adversarial network (GAN) is a class of machine learning frameworks and a prominent framework for approaching generative AI. The concept was initially developed by Ian Goodfellow and his colleagues in June 2014. In a GAN, two neural networks contest with each other in the form of a zero-sum game, where one agent's gain is another agent's loss.

Distributional data analysis is a branch of nonparametric statistics that is related to functional data analysis. It is concerned with random objects that are probability distributions, i.e., the statistical analysis of samples of random distributions where each atom of a sample is a distribution. One of the main challenges in distributional data analysis is that the space of probability distributions is, while a convex space, is not a vector space.

References

  1. 1 2 3 Arjovsky, Martin; Chintala, Soumith; Bottou, Léon (2017-07-17). "Wasserstein Generative Adversarial Networks". International Conference on Machine Learning. PMLR: 214–223.
  2. Weng, Lilian (2019-04-18). "From GAN to WGAN". arXiv: 1904.08994 [cs.LG].
  3. Nowozin, Sebastian; Cseke, Botond; Tomioka, Ryota (2016). "f-GAN: Training Generative Neural Samplers using Variational Divergence Minimization". Advances in Neural Information Processing Systems. Curran Associates, Inc. 29. arXiv: 1606.00709 .
  4. Arjovsky, Martin; Bottou, Léon (2017-01-01). "Towards Principled Methods for Training Generative Adversarial Networks". arXiv: 1701.04862 .{{cite journal}}: Cite journal requires |journal= (help)
  5. Miyato, Takeru; Kataoka, Toshiki; Koyama, Masanori; Yoshida, Yuichi (2018-02-16). "Spectral Normalization for Generative Adversarial Networks". arXiv: 1802.05957 [cs.LG].
  6. Gulrajani, Ishaan; Ahmed, Faruk; Arjovsky, Martin; Dumoulin, Vincent; Courville, Aaron C (2017). "Improved Training of Wasserstein GANs". Advances in Neural Information Processing Systems. Curran Associates, Inc. 30.

Notes

  1. In practice, the generator would never be able to reach perfect imitation, and so the discriminator would have motivation for perceiving the difference, which allows it to be used for other tasks, such as performing ImageNet classification without supervision.
  2. This is not how it is really done in practice, since is in general intractable, but it is theoretically illuminating.