D EMYSTIFYING MMD GAN S
Anonymous authors
Paper under double-blind review
A BSTRACT
We investigate the training and performance of generative adversarial networks using the Maximum Mean Discrepancy (MMD) as critic, termed MMD GANs.
As our main theoretical contribution, we clarify the situation with bias in GAN loss functions raised by recent work: we show that gradient estimators used in the optimization process for both MMD GANs and Wasserstein GANs are unbiased but learning a discriminator based on samples leads to biased gradients for the generator parameters.
We also discuss the issue of kernel choice for the MMD critic, and characterize the kernel corresponding to the energy distance used for the Cramér GAN critic.
Being an integral probability metric, the MMD beneﬁts from training strategies recently developed for Wasserstein GANs.
In experiments, the MMD GAN is able to employ a smaller critic network than the Wasserstein GAN, resulting in a simpler and faster-training algorithm with matching performance.
We also propose an improved measure of GAN convergence, the Kernel Inception Distance , and show how to use it to dynamically adapt learning rates during GAN training.
I NTRODUCTION
Generative Adversarial Networks (GANs; Goodfellow et al., 2014) provide a powerful method for general-purpose generative modeling of datasets.
Given examples from some distribution, a GAN attempts to learn a generator function, which maps from some ﬁxed noise distribution to samples that attempt to mimic a reference or target distribution.
The generator is trained to trick a discriminator , or critic , which tries to distinguish between generated and target samples.
This alternative to standard maximum likelihood approaches for training generative models has brought about a rush of interest over the past several years.
Likelihoods do not necessarily correspond well to sample quality (Theis et al., 2016), and GAN-type objectives focus much more on producing plausible samples, as illustrated particularly directly by Danihelka et al.
This class of models has recently led to many impressive examples of image generation (e.g. Huang et al., 2017a;b; Jin et al., 2017; Zhu et al., 2017).
GANs are, however, notoriously tricky to train (Salimans et al., 2016).
This might be understood in terms of the discriminator class.
Goodfellow et al.
(2014) showed that, when the discriminator is trained to optimality among a rich enough function class, the generator network attempts to minimize the Jensen-Shannon divergence between the generator and target distributions.
This result has been extended to general f -divergences by Nowozin et al.
According to Arjovsky & Bottou (2017), however, it is likely that both the GAN and reference probability measures are supported on manifolds within a larger space, as occurs for the set of images in the space of possible pixel values.
These manifolds might not intersect at all, or at best might intersect on sets of measure zero.
In this case, the Jensen-Shannon divergence is constant, and the KL and reverse-KL divergences are inﬁnite, meaning that they provide no useful gradient for the generator to follow.
This helps to explain some of the instability of GAN training.
The lack of sensitivity to distance, meaning that nearby but non-overlapping regions of high probability mass are not considered similar, is a long-recognized problem for KL divergence-based discrepancy measures (e.g. Gneiting & Raftery, 2007, Section 4.2).
It is natural to address this problem using Integral Probability Metrics (IPMs; Müller, 1997): these measure the distance between probability measures via the largest discrepancy in expectation over a class of “well behaved” witness functions.
Thus, IPMs are able to signal proximity in the probability mass of the generator and reference distributions.
(Section 2 describes this framework in more detail.)
Arjovsky et al.
(2017) proposed to use the Wasserstein distance between distributions as the discriminator, which is an integral probability metric constructed from the witness class of 1-Lipschitz functions.
To implement the Wasserstein critic, Arjovsky et al.
originally proposed weight clipping of the discriminator network, to enforce k -Lipschitz smoothness.
Gulrajani et al.
(2017) improved on this result by directly constraining the gradient of the discriminator network at points between the generator and reference samples.
This new Wasserstein GAN implementation, called WGAN-GP, is more stable and easier to train.
A second integral probability metric used in GAN variants is the maximum mean discrepancy (MMD), for which the witness function class is a unit ball in a reproducing kernel Hilbert space (RKHS).
Generative adversarial models based on minimizing the MMD were ﬁrst considered by
Li et al.
and Dziugaite et al.
These works optimized a generator to minimize the
MMD with a ﬁxed kernel, either using a generic kernel on image pixels or by modeling autoencoder representations instead of images directly.
Sutherland et al.
(2017) instead minimized the statistical power of an MMD-based test with a ﬁxed kernel.
Such approaches struggle with complex natural images, where pixel distances are of little value, and ﬁxed representations can easily be tricked (as in the adversarial examples of Szegedy et al.
Adversarial training of the MMD loss is thus the obvious choice.
Here the kernel MMD is deﬁned on the output of a convolutional network, which is trained adversarially.
Recent notable work has made use of the IPM representation of the MMD to employ the same witness function regularization strategies as Arjovsky et al.
Gulrajani et al.
(2017), effectively corresponding to an additional constraint on the MMD function class.
Without such constraints, the convolutional features are unstable and difﬁcult to train (Sutherland et al., 2017).
Li et al.
(2017b) used the weight clipping strategy of Arjovsky et al., with additional constraints to encourage the kernel distribution embeddings to be injective.
In light of the observations by Gulrajani et al.
, however, we use a gradient constraint on the MMD witness function in the present work (see Sections 2.1 and 2.2).
Bellemare et al.
(2017)’s method, the Cramér GAN, also used the gradient constraint strategy of
Gulrajani et al.
in their discriminator network.
As we discuss in Section 2.3, the Cramér GAN discriminator is related to the energy distance, which is an instance of the MMD (Sejdinovic et al., 2013), and which can therefore use a gradient constraint on the witness function.
Note, however, that there are important differences between the Cramér GAN critic and the energy distance, which make it more akin to the optimization of a scoring rule: we provide further details in Appendix A.
Weight clipping and gradient constraints are not the only approaches possible: variance features (Mroueh et al., 2017) and constraints (Mroueh & Sercu, 2017) can work, as can other optimization strategies (Berthelot et al., 2017;
Li et al., 2017a).
Given that both the Wasserstein distance and the MMD are integral probability metrics, it is of interest to consider how they differ when used in GAN training.
Bellemare et al.
(2017) showed that optimizing the empirical Wasserstein distance can lead to biased gradients for the generator, as well as an explicit example where optimizing with these biased gradients leads the optimizer to incorrect parameter values, even in expectation. They then claim that the energy distance does not suffer from these problems.
As our main theoretical contribution, we substantially clarify the bias situation in Section 3. First, we show (Theorem 1) that the natural maximum mean discrepancy estimator, including the estimator of energy distance, has unbiased gradients when used “on top” of a ﬁxed deep network representation.
The generator gradients obtained from a trained representation, however, will be biased relative to the desired gradients of the optimal critic based on inﬁnitely many samples.
This situation is exactly analogous to WGANs: the generator’s gradients with a ﬁxed critic are unbiased, but gradients from a learned critic are biased with respect to the supremum over critics.
MMD GANs, though, do have some advantages over Wasserstein GANs.
Certainly we would not expect the MMD on its own to perform well on raw image data, since these data lie on a low dimensional manifold embedded in a higher dimensional pixel space.
Once the images are mapped through appropriately trained convolutional layers, however, they can follow a much simpler distribution with broader support across the mapped domain: a phenomenon also observed in autoencoders (Bengio et al., 2013).
In this setting, the MMD with characteristic kernels (Sriperumbudur et al., 2010) shows strong discriminative performance between distributions.
To achieve comparable performance, a WGAN without the advantage of a kernel on the transformed space requires many more convolutional ﬁlters in the critic.
In our experiments (Section 5), we ﬁnd that MMD GANs achieve the same generator performance as WGAN-GPs with smaller discriminator networks, resulting in GANs with fewer parameters and easier training.
Thus, the MMD GAN discriminator can be understood as a hybrid model that plays to the strengths of both the initial convolutional mappings and the kernel layer that sits on top.
L OSSES AND WITNESS FUNCTIONS
We begin with a review of the MMD and relate it to the loss functions used by other GAN variants.
Through its interpretation as an integral probability metric, we show that the gradient penalty of
Gulrajani et al.
(2017) applies to the MMD GAN.
2. M AXIMUM M EAN D ISCREPANCY AND WITNESS FUNCTIONS
We consider a random variable X with probability measure P , which we associate with the generator, and a second random variable Y with probability measure Q , which we associate with the reference sample that we wish to learn.
Our goal is to measure the distance from P to Q using samples drawn independently from each distribution.
The maximum mean discrepancy is a metric on probability measures (Gretton et al., 2012), which falls within the family of integral probability metrics (Müller, 1997); this family includes the Wasserstein and Kolmogorov metrics, but not for instance the KL or χ 2 divergences.
Integral probability metrics make use of a class of witness functions to distinguish between P and Q , choosing the function with the largest discrepancy in expectation over P , Q , [Equation]
[Equation]
The particular witness function class F determines the probability metric.
For example, the
Wasserstein-1 metric is deﬁned using the 1-Lipschitz functions, the total variation by functions with absolute value bounded by 1, and the Kolmogorov metric using the functions of bounded variation 1 .
For more on this family of distances, see e.g. (Sriperumbudur et al., 2009b).
In this work, our witness function class F will be the unit ball in a reproducing kernel Hilbert space
H , with positive deﬁnite kernel k ( x, x (cid:48) ) .
The key property of a reproducing kernel Hilbert space is the reproducing property: for all f ∈ H , f ( x ) = (cid:104) f, k ( x, · ) (cid:105) H .
We deﬁne the mean embedding of the probability measure P as the element µ P ∈ H such that E P f
( X ) =
(cid:104) f, µ P (cid:105) H ; it is given by µ P = E X ∼ P k ( · , X ) .
The maximum mean discrepancy (MMD) is deﬁned as (1) with F the unit ball in H ,
[Equation]
The witness function f ∗ that attains the supremum has a straightforward expression (Gretton et al., 2012, Section 2.3),
[Equation]
Given samples X
= { x i } mi =1 drawn i.i.d.
from P , and Y = { y j } nj =1 drawn i.i.d.
from Q , the empirical witness function is
[Equation]
and an unbiased estimator of the squared MMD is (Gretton et al., 2012, Lemma 6)
MMD
[Equation]
[Equation]
When the kernel is characteristic (Sriperumbudur et al., 2010; 2011), the embedding µ P is injective (i.e., associated uniquely with P ).
Perhaps the best-known characteristic kernel is the exponentiated quadratic kernel, also known as the Gaussian RBF kernel,
[Equation]
Both the kernel and its derivatives decay exponentially, however, causing signiﬁcant problems in high dimensions, and especially when used in gradient-based representation learning.
The rational quadratic kernel
[Equation]
with α > 0 corresponds to a scaled mixture of exponentiated quadratic kernels, with a Gamma( α, 1) prior on the inverse lengthscale (Rasmussen & Williams, 2006, Section 4.2).
This kernel will be the mainstay of our experiments, as its tail behaviour is much superior to that of the exponentiated quadratic kernel; it is also characteristic.
2. W ITNESS FUNCTION AND GRADIENT PENALTIES
The MMD has been a popular choice for the role of a critic in a GAN.
This idea was proposed simultaneously by Dziugaite et al.
(2015) and Li et al.
(2015), with numerous recent follow-up works (Sutherland et al., 2017; Liu, 2017;
Li et al., 2017b; Bellemare et al., 2017).
As a key strategy in these recent works, the MMD of (4) is not computed directly on the samples; rather, the samples ﬁrst pass through a mapping function h , generally a convolutional network.
Note that we can think of this either as the MMD with kernel k on features h ( x ) , or simply as the MMD with kernel κ ( x, y )
=
k ( h ( x ) , h ( y )) .
The challenge is to learn the features h so as to maximize the MMD, without causing the critic to collapse to a trivial answer early in training.
Bearing in mind that the MMD is an integral probability metric, strategies developed for training the Wasserstein GAN critic can be directly adopted for training the MMD critic.
Li et al.
(2017b) employed the weight clipping approach of Arjovsky et al.
(2017), though they motivated it using different considerations.
Gulrajani et al.
(2017) found a number of issues with weight clipping, however: it oversimpliﬁes the loss functions given standard architectures, the gradient decays exponentially as we move up the network, and it seems to require the use of slower optimizers such as
RMSProp rather than standard approaches such as Adam (Kingma & Ba, 2015).
It thus seems preferable to adopt Gulrajani et al.
’s proposal of regularising the critic witness (3) by constraining its gradient norm to be nearly 1 along randomly chosen convex combinations of generator and reference points, αx i + (1 − α )
y j for α ∼ Uniform(0 , 1) .
This was motivated by the observation that the Wasserstein witness satisﬁes this property (their Lemma 1), but perhaps its main beneﬁt is one of regularization: if the critic function becomes too ﬂat anywhere between the samples, the generator cannot easily follow its gradient.
We will thus follow this approach, as did
Bellemare et al.
(2017), whose model we describe next.
2. T HE ENERGY DISTANCE AND ASSOCIATED MMD
Liu (2017) and Bellemare et al.
(2017, Section 4) proposed to use the energy distance as the critic in an adversarial network.
The energy distance (Székely & Rizzo, 2004; Lyons, 2013) is a measure of divergence between two probability measures, deﬁned as
[Equation]
where E P ρ ( X, X (cid:48) ) is an expectation over two independent samples from the generator P (likewise,
Y and Y (cid:48) are independent samples from the reference Q ), and ρ ( x, y ) is a semimetric of negative type.
4 We will focus on the case ρ β ( x, y )
= (cid:107) x − y (cid:107) β for 0 < β ≤ 2 .
When β ≤ 1 , ρ β is a metric.
It has been shown (Sejdinovic et al., 2013, Lemma 12) that the energy distance is an instance of the maximum mean discrepancy, where the corresponding distance-induced kernel family for the distance (7) is
[Equation]
for any choice of z 0 ∈ X (often z 0 = 0 is chosen to simplify notation, which corresponds to a fractional Brownian motion kernel; Sejdinovic et al., 2013, Example 15).
Note that the resulting kernel is not translation invariant.
It is characteristic (when β < 2 ), and the MMD is well-deﬁned for a class of distributions P that satisfy a moment condition (Sejdinovic et al., 2013, Remark 21), namely that there exists z 0 ∈ X such that
[Equation]
To apply the regularization strategy of Gulrajani et al.
(2017) in training the critic of an adversarial network, we need to compute the form taken by the witness function (2) given the kernel (8).
Bearing in mind that
[Equation]
where the second term of the above expression is constant, and substituting into (2), we have
[Equation]
This is in agreement with Bellemare et al.
’s function f ∗ (their page 5), albeit via a different argument (note that the function g ∗ in their footnote 4 is not correct, as it is missing the constant terms).
We now turn to the divergence implemented by the critic in Bellemare et al.’s
Algorithm 1, which is somewhat different from the energy distance (7).
The Cramér GAN witness function is deﬁned as
[Equation]
which is regularized using Gulrajani et al.
’s gradient constraint.
The expected surrogate loss associated with this witness function, and used for the Cramér critic, is
[Equation]
In brief, Y (cid:48) in (7) is replaced by the origin: it is explained that this is necessary for instance in the conditional case, where two independent reference samples Y, Y (cid:48) are not available.
Unfortunately, following this change, it becomes straightforward to deﬁne P and Q which are different, yet have an expected D c ( P , Q ) loss of zero.
For example, if P is a point mass at the origin in R , and Q is a point mass a distance t from the origin, then P (cid:54) =
Q and yet D c ( P , Q )
=
because
[Equation]
Nevertheless, good empirical performance has been obtained in practice for the Cramér critic, both by Bellemare et al.
(2017) and in our experiments of Section 5.
Our Appendix A provides some insight into this behavior by considering the Cramér critic’s relationship to the score function associated with the energy distance.
2. O THER RELATED MODELS
Many other GAN variants fall into the framework of IPMs (e.g. Mroueh et al., 2017; Mroueh &
Sercu, 2017; Berthelot et al., 2017).
Notably, although Goodfellow et al.
(2014) motivated GANs as estimating the Jensen-Shannon divergence, they can also be viewed as minimizing the IPM deﬁned by the classiﬁer family (Arora et al., 2017; Liu et al., 2017), thus motivating applying the gradient penalty to original GANs (Fedus et al., 2017).
(Liu et al., 2017) in particular studies properties of these distances.
G RADIENT BIAS
The issue of biased gradients in GANs was brought to prominence by Bellemare et al.
(2017, Section 3), who showed bias in the gradients of the empirical Wasserstein distance for ﬁnite sample sizes, and demonstrated cases where this bias could lead to serious problems in stochastic gradient descent, even in expectation.
They then claimed that the energy distance used in the Cramér GAN critic does not suffer from these problems.
We will now both formalize and clarify these results.
First, Bellemare et al.
’s
proof that the gradient of the energy distance is unbiased was incomplete: the essential step in the reasoning, the exchange in the order of the expectations and the derivatives, is simply assumed.
We show that one can exchange the order of expectations and derivatives, under very mild assumptions about the distributions in question, the form of the network, and the kernel:
Theorem 1.
Let G ψ : Z → X and h θ : X → R d be deep networks, with parameters ψ ∈
R m ψ and θ ∈ R m θ , of the form deﬁned in Appendix C.1 and satisfying Assumptions C and D .
This includes almost all feedforward networks used in practice, in particular covering convolutions, max pooling, and ReLU activations.
Let P be a distribution on X such that E [ (cid:107) X (cid:107) 2 ] exists, and likewise Z a distribution on Z such that E [ (cid:107) Z (cid:107) 2 ] exists.
P and Z need not have densities.
Let k : R d × R d → R be a kernel function satisfying the growth assumption Assumption E for some α ∈ [1 , 2] .
All kernels considered in this paper satisfy this assumption; see the discussion after
Corollary 3.
For µ - almost all ( ψ, θ ) ∈ R m ψ + m θ , where µ is the Lebesgue measure, the function
[Equation]
is differentiable at ( ψ, θ ) and moreover
[Equation]
Thus for µ -almost all (
[Equation]
This result is shown in Appendix C, speciﬁcally as Corollary 3 to Theorem 4, which is a quite general result about interchanging expectations and derivatives of functions of deep networks.
The proof is more complex than a typical proof that derivatives and integrals can be exchanged, due to the non-differentiability of ReLU-like functions used in deep networks.
But this is not the whole story.
In WGANs, the generator attempts to minimize the loss function
[Equation]
based on an estimate ˆ W ( X , Y ) :
ﬁrst critic parameters θ are estimated on a “training set” X tr , Y tr , and then the distance is estimated on the remaining “test set” X te , Y te as
[Equation]
(See Appendix B for an explanation of the effective train-test split in training GANs.)
Theoremand Appendix B.4 show that this estimator ˆ W is biased.
This further almost certainly implies that ∇ ψ ˆ W is biased as well, by Theorem 3.
(Bellemare et al.’s
Appendix A.2 rather showed gradient bias in a different situation: ∇ W (ˆ P m , Q ) , where Q is a known distribution and ˆ P m is the empirical distribution of m samples from a distribution which changes as m increases.)
Yet, for ﬁxed θ , Corollary 1 shows that the estimator (13) is unbiased; it is only the procedure which ﬁrst selects a θ based on training samples and then evaluates (13) which is a biased estimator of (12).
The situation with MMD GANs, including energy distance-based GANs, is exactly analogous.
We have (11): for almost all particular critic representations h θ , the estimator of MMD 2 is unbiased.
But the population divergence the generator attempts to minimize is actually
[Equation]
a distance previously studied by Sriperumbudur et al.
(2009a) as well as Li et al.
(2017b).
An MMD
GAN’s effective estimator of ˆ η is also biased by Theorem 2 (see particularly Appendix B.5); by
Theorem 3, its gradients are also almost certainly biased.
In both cases, the bias vanishes as the selection of θ becomes better; in particular, no bias is introduced by the use of a ﬁxed (and potentially small) minibatch size, but rather by the optimization procedure for θ and the total number of samples seen in training the discriminator.
Yet there is at least some sense in which MMD GANs might be considered “less biased” than
WGANs.
Optimizing the generator parameters of a WGAN while holding the critic parameters ﬁxed is not sensible: consider, for example, P a point mass at 0 ∈ R and Q a point mass at q ∈ R .
If q > 0 , an optimal θ might correspond to the witness function f ( t ) =
t ; if we hold this witness function f ﬁxed, the optimal q is at −∞ , rather than at the correct value of 0 .
But if we hold an MMD GAN’s critic ﬁxed and optimize the generator, we obtain the GMMN model of Li et al.
; Dziugaite et al.
Here, because the witness function still adapts to the observed pair of distributions, the correct distribution P = Q will always be optimal.
Bad solutions might also seem to be optimal, but they can never seem arbitrarily better .
Thus unbiased gradients of MMD 2 u might somehow be more meaningful to the optimization process than unbiased gradients of (13); exploring and formalizing this intuition is an intriguing area for future work.
E VALUATION METRICS
One problem with comparing GAN models is that quantitative comparisons are difﬁcult.
Some insight can be gained by visually examining samples, but we also consider the following approaches to evaluate GAN methods.
Inception score This metric, proposed by Salimans et al.
(2016), is based on the classiﬁcation output p ( y | x ) of the Inception model (Szegedy et al., 2016).
Deﬁned as exp ( E x KL( p ( y | x ) (cid:107) p ( y )))
, it is highest when each image’s predictive distribution has low entropy, but the marginal p ( y ) =
E x p ( y | x ) has high entropy.
This score correlates somewhat with human judgement of sample quality on natural images, but it has some issues, especially when applied to domains which do not represent a variety of the types of classes in ImageNet.
In particular, it knows nothing about the desired distribution for the model.
FID The Fréchet Inception Distance , proposed by Heusel et al.
(2017), avoids some of the problems of Inception by measuring the similarity of the samples’ representations in the Inception architecture (at the pool3 layer) to those of samples from the target distribution.
The FID ﬁts a Gaussian distribution to the hidden activations for each distribution and then computes the Fréchet distance, also known as the Wasserstein-2 distance, between those Gaussians.
Heusel et al.
show that unlike the Inception score, the FID worsens monotonically as various types of artifacts are added to images.
Note, however, that the estimator of FID is biased.
KID We propose a metric similar to the FID, the Kernel Inception Distance , to be the squared
MMD between Inception representations.
We use a polynomial kernel, k ( x, y )
= (cid:0) 1 d x T y + {+
+}
(cid:1)where d is the representation dimension, to avoid correlations with the objective of MMD GANs as well as to avoid tuning any kernel parameters; 7 this can also be viewed as an MMD directly on input images with the kernel K ( x, y ) =
k ( φ ( x ) , φ ( y )) , with φ the function mapping images to
Inception representations.
Compared to the FID, the KID has several advantages.
First, it does not assume a parametric form for the distribution of activations.
This is particularly sensible since the representations have ReLU activations, and therefore are not only never negative, but do not even have a density: about 2% of components in Inception representations are typically exactly zero.
With the cubic kernel we use here, the KID compares skewness as well as the mean and variance.
Also, unlike the FID, the KID has a simple unbiased estimator.
Figure 1 demonstrates the bias of the FID and the unbiasedness of the KID by comparing the CIFAR10 train and test sets.
The KID (Figure 1a) converges quickly to its presumed true value of 0; even [Figure] for very small n , simple Monte Carlo estimates of the variance provide a reasonable measure of uncertainty.
By contrast, the FID estimate (Figure 1b) does not behave so nicely: at n = 2 000 , when the KID estimator is essentially always 0, the FID estimator is still quite large.
Even at n = 10 000 , the full size of the CIFAR test set, the FID still seems to be decreasing from its estimate of about 8.1 towards zero, showing the strong persistence of bias.
This highlights that FID scores can only be compared for speciﬁc values of n ; even then, there is no particular reason to expect the bias to be the same between different pairs of distributions, so comparing estimates is quite risky.
Moreover, Monte Carlo estimates of the variance are extremely small even when the estimate is very far from its asymptote, so it is difﬁcult to judge the reliability of an estimate, and practitioners may be mislead by the very low variance into thinking that they have obtained the true value.
For models on MNIST, we replace the Inception featurization with features from a LeNet-like convolutional classiﬁer 8 (LeCun et al., 1998), but otherwise compute the scores in the same way.
We also considered the diagnostic test of Arora & Zhang (2017), which estimates the approximate number of “distinct” images produced by a GAN.
The amount of subjectivity in what constitutes a duplicate image, however, makes it hard to reliably compare models based on this diagnostic.
Comparisons probably need to be performed both with a certain notion of duplication in mind and by a user who does not know which models are being compared, to avoid subconscious biases; we leave further exploration of this intriguing procedure to future work.
4. L EARNING RATE ADAPTATION
In supervised deep learning, it is common practice to dynamically reduce the learning rate of an optimizer when it has stopped improving the metric on a validation set.
So far, this does not seem to be common in GAN-type models, so that learning rate schedules must be tuned by hand.
We propose using an adaptive scheme, based on comparing the KID score for samples from a previous iteration to that from the current iteration.
To avoid setting an explicit threshold on the change in the numerical value of the score, we use a p -value obtained from the relative similarity test of Bounliphone et al.
(2016): if the test does not indicate that our current model is closer to the validation set than the model from a certain number of iterations ago at a given signiﬁcance level, we mark it as a failure; when a given number of failures occur in a row, we decrease the learning rate.
Bounliphone et al.
’s
test is for the hypothesis
MMD ( P , Q ) < MMD ( P (cid:48) , Q ) , and since the KID can be viewed as an MMD on image inputs, we can apply it directly.
(We use the slight corrections to the asymptotic distribution of the MMD estimator given by Sutherland et al.
(2017) in this test.)
E XPERIMENTS
We compare the quality of samples generated by MMD GAN using various kernels with samples obtained by WGAN-GP (Gulrajani et al., 2017) and Cramér GAN (Bellemare et al., 2017) on three standard benchmark datasets: the MNIST dataset of 28 × 28 handwritten digits 9 , the CIFARdataset of 32 × 32 photos (Krizhevsky, 2009), and LSUN dataset of 64 × 64 pictures of bedrooms
Yu et al.
For all of our experiments we used the DCGAN architecture (Radford et al., 2016) for both generator and critic.
For MMD losses, we used only 16 top-layer neurons in the critic; more did not seem to improve performance, except for the distance kernel for which 256 neurons in the top layer was advantageous.
As Bellemare et al.
(2017) advise use of at least 256-dimensional critic output, this enabled exact comparison between Cramér GAN and energy distance MMD, which are directly related (Section 2.3).
For the generator we used the standard number of convolutional ﬁlters ( in the second-to-last layer); for the critic, we compared networks with 16 and 64 ﬁlters in the ﬁrst convolutional layer.
Models with smaller critics run considerably faster: on our systems, the 16-ﬁlter networks typically ran at about twice the speed of the 64-ﬁlter ones.
Note that the critic size is far more important to training runtime than the generator size: we update the critic 5 times for each generator step, and moreover the critic network is run on two batches each time we use it, one from P and one from Q .
Given the same architecture, all models considered here run at about the same speed.
We evaluate several MMD GAN kernel functions in our experiments.
The simplest is the linear kernel: k dot ( x, y ) = (cid:104) x, y (cid:105) , whose MMD corresponds to the distance between means (this is somewhat similar to the feature matching idea of Salimans et al., 2016).
We also use the exponentiated quadratic (5) and rational quadratic (6) functions, with mixtures of lengthscales,
[Equation]
where Σ = { 2 , 5 , 10 , 20 , 40 , 80 } , A = { . 2 , .
For the latter, however, we found it advantageous to add a linear kernel to the mixture, resulting in the mixed RQ-dot kernel k rq ∗ =
k rq + k dot .
Lastly we use the distance-induced kernel k dist ρ 1 , 0 of (8), using the Euclidean distance ρ 1 so that
the
MMD is the energy distance.
We also considered Cramér GANs, with the surrogate critic (10), and
WGAN-GPs.
We also found it helpful to add an activation penalty to the critic representation network in certain
MMD models.
Otherwise the representations h
θ sometimes chose very large values, which for most kernels does not change the theoretical loss (deﬁned only in terms of distances) but leads to ﬂoatingpoint precision issues.
We use a combined L 2 penalty on activations across all critic layers, with a factor of 1 for RQ-dot kernel and 0 .
0001 for distance kernel.
Each model was trained with a batch size of 128, and 5 discriminator updates per generator update.
For CIFAR-10 and LSUN we trained for 150 000 generator updates, while for MNIST we used 50 000 .
The initial learning rate was set to 10 − 4 and followed the adaptive scheme described in
Section 4.1, with KID compared between the current model and the model 20 000 generator steps earlier ( 5 000 for MNIST), every 2 000 steps ( 500 for MNIST).
After 3 consecutive failures to improve, the learning rate was halved.
This approach allowed us not to pick a different learning rate for each of the considered models, which would otherwise have been needed.
We scale the gradient penalty by 1 , instead of the 10 recommended by Gulrajani et al.
(2017) and
Bellemare et al.
; we found this to usually work slightly better with MMD models.
With the distance kernel, however, we scale the penalty by 10 to allow direct comparison with Cramér GAN.
MNIST After training for 50 000 generator iterations, all variants achieved reasonable results.
Among MMD models, only the distance kernel saw an improvement with more neurons in the top layer.
Table 1 shows the quantitative measures, computed on the basis of a LeNet model.
All have achieved KIDs of essentially zero, and FIDs around the same as that of the test set, with Inception scores slightly lower.
Figure 5, in Appendix D, shows samples.
[Table]
Figure 2, however
[Table]
shows the evolution of our quantitative criteria throughout the training process for several models.
This shows that the linear kernel dot and rbf kernel rbf are clearly worse than the other models at the beginning of the training process, but both make an improvement once learning rates are adapted to their needs.
rbf however does not catch up fully with the other models.
Examining samples during training, we observed that rbf more frequently produces extremely “blurry” outputs, which can persist for a substantial amount of time before eventually resolving.
This makes sense, given the very fast gradient decay of the rbf kernel: when generator samples are extremely far away from the reference samples, slight improvements yield very little reward for the generator, and so bad samples can stay bad for a long time.
[Figure]
There is also some evidence that dist , and perhaps WGAN-GP, converge more slowly than rq and
Cramér GAN.
Given their otherwise similar properties, we thus recommend the use of rq kernels over rbf in MMD GANs.
CIFAR-10 Scores for various models trained on CIFAR-10 are shown in Table 2.
The scores for rq with a small critic network approximately match those of WGAN-GP with a large critic network, at substantially reduced computational cost.
With a small critic, WGAN-GP, Cramér GAN and the distance kernel all performed very poorly.
Samples from these models are presented in Appendix D.
LSUN Bedrooms Table 3 presents scores for models trained on the LSUN Bedrooms dataset; samples from most of these models are shown in Figure 3.
Comparing the models’ Inception scores with the one achieved by the test set makes clear that this measure is not meaningful for LSUN dataset.
This is not overly surprising, given that the Inception score is based on ImageNet class labels, a very different domain from the kinds of images seen among LSUN bedrooms.
In terms of KID and FID, MMD GANs outperform Cramér and WGAN-GP for each critic size.
Although results with smaller critic are worse than with large one for each considered model, MMD
GANs still produce reasonably good samples, which certainly is not the case for WGAN-GP.
Although Cramér GAN produces relatively good samples, the separate objects in these pictures often seem melted together and they are not as sharp as in MMD rq * samples.
With large critic, both
Cramér GAN and MMD rq * give good quality samples, many of which are hardly distinguishable from the test set by eye.
[Table] [Table]
WGAN
[Table]
WGAN
[Table]
GP
[Table]
These results illustrate the beneﬁts of using the MMD on deep convolutional feaures as a GAN critic.
In this hybrid system, the initial convolutional layers map the generator and reference image distributions to a simpler representation, which is well suited to comparison via the MMD.
The
MMD in turn employs an inﬁnite dimensional feature space to compare the outputs of these convolutional layers.
By comparison, WGAN-GP requires a larger discriminator network to achieve similar performance.
It is interesting to consider the question of kernel choice: the distance kernel and RQ kernel are both characteristic (Sriperumbudur et al., 2010), and neither suffers from the fast decay of the exponentiated quadratic kernel, yet the RQ kernel performs slightly better in our experiments.
The relative merits of different kernel families for GAN training will be an interesting topic for further study.
A S CORE FUNCTIONS , DIVERGENCES , AND THE C RAMÉR GAN
It is not immediately obvious how to interpret the surrogate loss (10).
An insight comes from considering the score function associated with the energy distance, which we now brieﬂy review (Gneiting & Raftery, 2007).
A scoring rule is a function S ( P , y ) , which is the loss incurred when a forecaster makes prediction P , and the event y is observed.
The expected score is the expectation under Q of the score,
[Equation]
If a score is proper , then the expected score obtained when P = Q is greater or equal than the expected score for P (cid:54) =
Q ,
S ( Q
[Equation]
Q
[Equation]
≥ S ( P , Q ) .
A strictly proper scoring rule shows an equality only when P and Q agree.
We can deﬁne a divergence measure based on this score,
[Equation]
Bearing in mind the deﬁnition of the divergence (15), it is easy to see (Gneiting & Raftery, 2007, eq. 22) that the energy distance (7) arises from the score function
[Equation]
The interpretation is straightforward: the score of a reference sample y is determined by comparing its average distance to a generator sample with the average distance among independent generator samples, E P ρ ( X, X (cid:48) ) .
As discussed earlier, the Cramér GAN critic does not use the energy distance (7) directly on the samples, but ﬁrst maps the samples through a function h , for instance a convolutional network; this should be chosen to maximize the discriminative performance of the critic.
Writing this mapping as h , we break the energy distance down as D e ( P , Q ) =
S ( Q , Q ) − S ( P , Q ) , where
[Equation]
16) and
[Equation]
When training the discriminator, the goal is to maximize the divergence by learning h , and so both (16) and (17) change: in other words, divergence maximization is not possible without two independent samples Y, Y (cid:48) from the reference distribution Q .
An alternative objective in light of the score interpretation, however, is to simply optimize the average score (17).
In other words, we would ﬁnd features h that make the average distance from generator to reference samples much larger than the average distance between pairs of generator samples.
We no longer control the term encoding the “variability” due to Q , E Q ρ ( h ( Y ) , h ( Y (cid:48) )) , which might therefore explode: for instance, h might cause h ( Y ) to disperse broadly, and far from the support of P , assuming sufﬁcient ﬂexibility to keep E P ρ ( h ( X ) , h ( X (cid:48) )) under control.
We can mitigate this by controlling the expected norm E Q ρ ( h ( Y ) , 0) , which has the advantage of only requiring a single sample to compute.
For example, we could maximize
[Equation]
This resembles the Cramér GAN critic (10), but the generator-to-generator distance is scaled differently, and there is an additional term: E P ρ ( h ( X ) , 0) is being maximized, which is more difﬁcult to interpret.
An argument has been made (in personal communication with Bellemare et al.)
that this last term is required if the function f c in (9) is to be a witness of an integral probability metric (1), although the asymmetry of this witness in P vs Q needs to be analyzed further.
B B IAS OF GENERALIZED IPM ESTIMATORS
We will now show that estimators of IPM-like distances based on data splitting are biased.
Appendix B.1 deﬁnes a slight generalization of IPMs, used to analyze MMD GANs in the same framework as WGANs, and a class of estimators that are a natural model for the estimator used in GAN models.
Appendix B.2 shows that such estimators are invariably biased in nontrivial cases; Appendix B.3 then demonstrates that any estimator with non-constant bias yields a biased gradient estimator.
Appendices B.4 and B.5 demonstrate speciﬁc examples of this bias for the Wasserstein and maximized-MMD distances.
B. G ENERALIZED IPM S AND DATA - SPLITTING ESTIMATORS
We will ﬁrst deﬁne a slight generalization of IPMs: we will use this added generality to help analyze
MMD GANs in Appendix B.5.
Deﬁnition 1 (Generalized IPM) .
Let X be some domain, with M a class of probability measures on X .
Let F be some parameter set, and J : F × M × M → R an objective functional.
The generalized IPM D : M × M → R is then given by
[Equation]
For example, if F is a class of functions f : X → R , and J is given by
[Equation]
then we obtain integral probability metrics (1).
Given samples X ∼ P m and Y ∼ Q n , let ˆ P denote the empirical distribution of X (an equal mixture of point masses at each X i ∈ X ), and similarly ˆ Q for Y .
Then we have a simple estimator of (19) which is unbiased for ﬁxed f :
[Equation]
Deﬁnition 2 (Data-splitting estimator of a generalized IPM) .
Consider the distance (18) , with objective J and parameter class F .
Suppose we observe iid samples X ∼ P m , Y ∼ Q n , for any two distributions P , Q .
A data-splitting estimator is a function ˆ D F ( X , Y ) which ﬁrst randomly splits the sample X into X tr , X te and Y into Y tr , Y te , somehow selects a critic function ˆ f X tr , Y tr ∈ F independently of X te , Y te , and then returns a result of the form
[Equation]
where ˆ J ( f, X , Y ) is an estimator of J ( f, P , Q ) .
These estimators are deﬁned by three components: the choice of relative sizes of the train-test split, the selection procedure for ˆ f X tr , Y tr , and the estimator ˆ J .
The most obvious selection procedure is
[Equation]
though of course one could use regularization or other techniques to select a different f ∈ F , and in practice one will use an approximate optimizer.
Lopez-Paz & Oquab (2017) used an estimator of exactly this form in a two-sample testing setting.
As we optimize a WGAN-type model, we compute the loss (or its gradients) on a minibatch, while the current parameters of the critic are based only on data seen in previous iterations.
We can view the current minibatch as X te , Y te , all previously-seen data as X tr , Y tr , and the current critic function as ˆ f X tr , Y tr .
Thus, at least in the ﬁrst pass over the training set, WGAN-type approaches exactly ﬁt the data-splitting form of Deﬁnition 2.
B. E STIMATOR BIAS
These data-splitting estimators are, in general, biased downwards:
Theorem 2.
Consider a data-splitting estimator (Deﬁnition 2) of the generalized IPM D (Deﬁnition 1) based on an unbiased estimator ˆ J of J : for any ﬁxed f ∈ F ,
[Equation]
Then either the selection procedure is almost surely perfect,
[Equation]
(21) or else the estimator has a downward bias:
[Equation]
Proof of Theorem 2.
Since X tr , Y tr are independent of X te , Y te ,
[Equation]
Deﬁne the suboptimality of ˆ f X tr , Y tr as
[Equation]
J
[Equation]
ˆ f X
[Equation]
, Y
[Equation]
P
[Equation]
so that E ˆ D ( X , Y ) =
D ( P , Q ) − E [ ε ] .
Note that ε ≥ 0 , since D ( P , Q ) =
sup f ∈F J ( f, P , Q ) and so for any f ∈ F we have
[Equation]
Thus, either Pr( ε = 0)
= 1 , in which case (21) holds, or else E [ ε ] > 0 , giving (22).
Note that many estimators of IPMs do not actually perform this data splitting procedure, instead estimating D ( P , Q ) with the distance between empirical distributions D (ˆ P , ˆ Q ) .
The standard biased estimator of the MMD (Gretton et al., 2012, Equation 5), the IPM estimators of Sriperumbudur et al.
(2012), and the empirical Wasserstein estimator studied by Bellemare et al.
(2017) are all of this form.
Considering P = Q , so that D ( P , Q ) = 0 , but ˆ P (cid:54)
=
ˆ Q , so that D (ˆ P , ˆ Q ) > 0 , makes it clear that these estimators at least sometimes have an upwards bias.
Theorem 2 also makes clear that as ˆ f X tr , Y tr converges to its optimum, the bias of ˆ D should vanish (as in Bellemare et al., 2017, Theorem 3).
Moreover, in the GAN setting the minibatch size only directly determines X te , Y te , which do not contribute to this bias; bias is due rather to the training procedure and the number of samples seen through the training process.
As long as ˆ f X tr , Y tr is not optimal, however, the estimator will remain biased.
B. G RADIENT ESTIMATOR BIAS
We will now show that biased estimators, except for estimators with a constant bias, must also have biased gradients.
Assume that, as in the GAN setting, Q is given by a generator network G ψ with parameter ψ and inputs Z ∼ Z , so that Y =
G ψ ( Z ) ∼ Q ψ .
The generalized IPM of (18) is now a function of ψ , which we will denote as
[Equation]
Consider an estimator ˆ D ( ψ ) of D ( ψ ) .
Theorem 3 shows that when ˆ D ( ψ ) and D ( ψ ) are differentiable, the gradient ∇ ψ ˆ D ( ψ ) is an unbiased estimator for ∇ ψ D ( ψ ) only if the bias of ˆ D ( ψ ) doesn’t depend on ψ .
This is exceedingly unlikely to happen for the biased estimator ˆ D ( W ) deﬁned in
Theorem 2.
Theorem 3.
Let D : Ψ
→ R be a function on a parameter space Ψ ⊆ R d , with a random estimator ˆ D : Ψ → R which is almost surely differentiable.
Suppose that ˆ D has unbiased gradients:
[Equation]
Then, for each connected component of Ψ ,
[Equation]
where the constant can vary only across distinct connected components.
Proof.
Let ψ 1 and ψ 2 be an arbitrary pair of parameter values in Ψ , connected by some smooth path r : [0 , 1] → Ψ with r (0)
=
ψ 1 , r (1) = ψ 2 .
For example, if Ψ is convex, then paths of the form r ( t ) = tψ 1 + (1 − t ) ψ 2 are sufﬁcient.
Using Fubini’s theorem and standard results about path integrals, we have that
[Equation]
This implies that E [ˆ D ( ψ )]
= D ( ψ ) + const for all ψ in the same connected component of Ψ .
B. WGAN S
Theorem 2 holds for the original WGANs, whose critic functions are exactly L -Lipschitz, considering F as the set of L -Lipschitz functions so that D F is L times the Wasserstein distance.
It also holds for either WGANs or WGAN-GPs with F the actual set of functions attainable by the critic architecture, so that D is “neural network distance” of Arora et al.
(2017) or the “adversarial divergence” of Liu et al.
It should be obvious that for nontrivial distributions P and Q and reasonable selection criteria for ˆ f X tr , Y tr , (21) does not hold, and thus (22) does (so that the estimate is biased downwards).
Example For an explicit demonstration, consider the Wasserstein case, F the set of 1 -Lipschitz functions, with P = N (1 , 1) and Q = N (0 , 1) .
Here D F ( P , Q ) = 1 ; the only critic functions f ∈ F which achieve this are f ( t ) =
t + C for C ∈ R .
If we observe only one training pair X tr ∼ P and Y tr ∼ Q , when X tr > Y tr , f 1 ( t ) = t is a maximizer of (20), leading to the expected estimate J ( f 1 , P , Q ) = 1 .
But with probability Φ (cid:0) − 1 / √ 2 (cid:1) ≈ 0 .
24 it happens that
X tr < Y tr .
In such cases, (20) could give e.g. f − 1 ( t ) = − t , giving the expected response J ( f − 1 , P , Q ) = − 1 ; the overall expected estimate of the estimator using this critic selection procedure is then E ˆ D F
( X , Y )
= (cid:0) 1 − Φ (cid:0) − 1 / √ 2 (cid:1)(cid:1) − Φ (cid:0) − 1 / √ 2 (cid:1) ≈ 0 .
The only way to achieve E ˆ D F ( X , Y )
= 1 would be a “stubborn” selection procedure which chooses f 1 + C no matter the given inputs.
This would have the correct output E ˆ D F ( X , Y )
=for this ( P , Q ) pair.
Applying this same procedure to P = N ( − 1 , 1) and Q = N (0 , 1) , however, would then give E ˆ D F ( X , Y )
=
− 1 , when it should also be 1 .
B. M AXIMAL MMD ESTIMATOR
Recall the distance η
( P , Q ) =
sup θ MMD 2 ( h θ ( P ) , h θ ( Q )) deﬁned by (14).
MMD GANs can be viewed as estimating η according to the scheme of Theorem 2, with F the set of possible parameters θ , J ( θ, P , Q ) =
MMD 2 ( h θ ( P ) , h θ ( Q )) , and ˆ J ( θ, X , Y ) =
MMD 2 u ( h θ ( X ) , h θ ( Y )) .
Clearly our optimization scheme for θ does not almost surely yield perfect answers, and so again we have
[Equation]
As m tr , n tr → ∞ , as for Wasserstein it should be the case that ˆ η → η .
This is shown for certain kernels, along with the rate of convergence, by Sriperumbudur et al.
(2009a, Section 4).
Example For a particular case, consider
[Equation]
with h θ : R 2 → R given by h θ ( x ) = θ
T x , (cid:107) θ (cid:107) = 1 , so that h θ chooses a one-dimensional projection of the two-dimensional data.
Then use the linear kernel k dot , so that the MMD is simply the difference in means between projected features:
[Equation]
and
[Equation]
Clearly η ( P , Q ) = 1 , which is obtained by θ ∈ { ( − 1 , 0) , (1 , 0) } ; any other valid θ will yield a strictly smaller value of MMD 2 ( h θ ( P ) , h θ ( Q )) .
The MMD GAN estimator of η , if the optimum is achieved, uses
[Equation]
where A X tr , Y tr ∈ R 2 × 2 .
ˆ θ X tr , Y tr is then the normalized ﬁrst eigenvector of A X tr , Y tr .
For Gaussian
X tr , Y tr with ﬁnite m tr , n tr , ˆ θ X tr , Y tr is a continuous random variable and so does not almost surely lie in { ( − 1 , 0) , (1 , 0) } ; thus by Theorem 2, E ˆ η ( X , Y ) <
η ( P , Q ) = 1 .
(A numerical simulation for the former gives a value around 0 .
6 when m tr = n tr = 2 .)
C P ROOF OF UNBIASED GRADIENTS
We now proceed to prove Theorem 1, and indeed its generalization Theorem 4.
Exchanging the gradient and the expectation can often be guaranteed using a standard result in measure theory (see Proposition 1), as a corollary of the Dominated Convergence theorem (Proposition 2).
This result, however, requires the property Proposition 1.(ii): for almost all inputs X , the mapping is differentiable on the entirety of a neighborhood around θ .
This order of quantiﬁers is important: it allows the use of the mean value theorem to control the average rate of change of the function, and the result then follows from Proposition 2.
For a neural network with the ReLU activation function, however, this assumption doesn’t hold in general.
For instance, if θ = ( θ 1 , θ 2 ) ∈ R 2 with θ 2 (cid:54) = 0 and X ∈ R , one can consider this very simple function: h θ ( X ) =
max(0 , θ
1 + θ 2 X ) .
For any ﬁxed value of θ , the function h θ ( X ) is differentiable in θ for all X in R except for X θ = − θ 1 /θ 2 .
However, if we consider a ball of possible θ values B ( θ, r ) , the function is not differentiable on the set {− θ (cid:48) 1 /θ (cid:48) 2 ∈ R | θ (cid:48)
∈ B ( θ, r ) } , which can have positive measure for many possible distributions for X .
In Theorem 4, we provide a proof of Theorem 1 for all parameter values outside of a “bad set” Θ P , without relying on Proposition 1.(ii).
This can be done using Lemma 1, which takes advantage of the particular structure of neural networks to control the average rate of change without using the mean value theorem.
Dominated convergence (Proposition 2) can then be applied directly.
We also show in Proposition 3 that the set Θ P , of parameter values where Theorem 4 might not hold, has zero Lebesgue measure.
This relies on the standard Fubini theorem (Klenke, 2008, Theorem 14.16) and Lemma 3, which ensures that the network θ (cid:55)→ h θ ( X ) is differentiable for almost all parameter values θ when X is ﬁxed.
Although Lemma 3 might at ﬁrst sight seem obvious, it requires some technical considerations in topology and differential geometry.
Proposition 1 (Differentiation Lemma (e.g. Klenke, 2008, Theorem 6.28)) .
Let V be a nontrivial open set in R m and let P be a probability distribution on R d .
Deﬁne a map h : R d × V (cid:55)→ R n with the following properties:
(i)
For any θ ∈ V , E P [ (cid:107) h θ ( X ) (cid:107) ] < ∞ .
(ii) For P -almost all X ∈ R d , the map
V
→ R n , θ (cid:55)→ h θ ( X ) is differentiable.
(iii)
There exists a P -integrable function g : R d (cid:55)→ R such that (cid:107) ∂ θ h θ ( X ) (cid:107) ≤ g ( X ) for all θ ∈ V .
Then, for any θ ∈ V , E P [ (cid:107) ∂
θ h θ ( X ) (cid:107) ] < ∞ and the function θ (cid:55)→ E P [ h θ ( X )] is differentiable with differential:
[Equation]
Proposition 2 (Dominated Convergence Theorem (e.g. Klenke, 2008, Corollary 6.26)) .
Let P be a probability distribution on R d and f a measurable function.
Let ( f n ) n ∈ N be a sequence of of integrable functions such that for P -almost all X ∈ R d , f n ( X ) → f ( X ) as n goes to ∞ .
Assume that there is a dominating function g : (cid:107) f n ( X ) (cid:107) ≤ g ( X ) for P -almost all X ∈ R d for all n ∈ N , and E P [ g ( X )] < ∞ .
Then f is P -integrable, and E P [ f n ( X )]
→ E P [ f ( X )] as n goes to ∞ .
C. N ETWORK DEFINITION
We would like to consider general feed-forward networks with a directed acyclic computation graph
G .
Here, G consists of L + 1 nodes, with a root node i = 0 and a leaf node i =
L .
We denote by π ( i ) the set of parent nodes of i .
The nodes are sorted according to a topological order: if j is a parent node of i , then j < i .
Each node i for i > 0 computes a function f i , which outputs a vector in R d i based on its input in R d π ( i ) , the concatenation of the outputs of each layer in π ( i ) .
Here d π ( i ) =
(cid:80)
j ∈ π
( i )
d j , and d 0 = d > 0 .
We deﬁne the feed-forward network that factorizes according the graph G and with functions
f i recursively:
[Equation]
h π ( i ) is the concatenation of the vectors h j for j ∈ π ( i ) .
The functions f i can be of two types:
• Afﬁne transform (Linear Module) :
[Equation]
W i is a vector of dimension m i .
The function g i :
R m i → R d i × ( d π ( i ) +1) is a known linear operator on the weights W i , which can account for convolutions and similar linear operations.
We will sometimes use (cid:101) Y to denote the augmented vector (cid:20) Y (cid:21) , which accounts for bias terms.
• Non-linear : These f i have no learnable weights.
f i can potentially be non-differentiable, such as max pooling, ReLU, and so on.
Some conditions on f i will be required (see Assumption D ); the usual functions used in practice satisfy these conditions.
Denote by C the set of nodes i such that f i is non-linear.
θ is the concatenation of parameters of all linear modules: θ =
( W k ) k ∈ C c , where C c is the complement of C in [ L ] = { 1 , ..., L } .
Call the total number of parameters m = (cid:80) i ∈
C c m i , so that θ ∈ R m .
The feature vector of the network corresponds to the output of the last node L and will be denoted h θ :=
h Lθ ∈ R d L .
The subscript θ stands for the parameters of the network.
Domain of analyticity For a given node i ∈ C , we assume the domain of analiticity D
i for the function f
i to be the union of K i disjoint sets:
[Equation]
To control the topology of these sets, we assume that each set D ki is deﬁned by S i,k real analytic functions G i,k,s : R d π → R :
[Equation]
We assume that (cid:83) K i k
=1 ¯ D ki = R d π ( i ) and that the D ki are disjoint.
We are interested in the case where f i is real analytic on each one of the domains D ki , but might be non-differentiable at their borders (see Assumption D ).
This includes most of the functions used for deep learning, including ReLU,
Leaky ReLU, max-pooling, and so on.
Y
Y 2  (a
[Figure]
Domains of analyticity for the ReLU function in
[Figure]
Y Y
[Figure]
For example, if f i computes the ReLU activation function on two inputs, then we have K i = 4 , with each D ki corresponding to a quadrant of the real plane (see Figure 4a).
These quadrants might each be deﬁned by S i,k = 2 inequalities of the form G i,k, 1 ( Y ) > 0 and G i,k, 2 ( Y ) > 0 , where
G i,k,s ( Y ) = ± Y 1 and G i,k,s ( Y ) = ±
Y 2 are analytic.
Moreover, on each of these domains f i coincides with an analytic function:
[Equation]
Another example is when f i computes max-pooling on two inputs.
In that case we have K i = 2 , and each domain D ki corresponds to a half plane (see Figure 4b ).
Each domain is deﬁned by one inequality G i,k, 1 ( Y ) > 0 with G i, 1 , 1 ( Y ) =
Y 1 − Y 2 and G i, 2 , 1 ( Y ) =
Y 2 − Y 1 .
Again, G i,k, 1 are analytic functions and f i coincides with an analytic function on each of the domains:
[Equation]
When f i is analytic on the whole space, D i =
R d π ( i ) , we can choose K i
= 1 to get D 1 i = R d π ( i ) , which can be deﬁned by a single function ( S i,k = 1 ) of G i, 1 , 1 ( Y )
= 1 .
This case corresponds to most of the differentiable functions used in deep learning, such as the softmax, sigmoid, hyperbolic tangent, and batch normalization functions.
Index sets For a given node i , the following sets will be used extensively:
[Equation]
Note that ∂i ⊆
¬ i , and that ¬ i =
∂i ∪ ¬ π ( i ) .
Furthermore, if a ( i ) is the set of ancestors of node i , we deﬁne a backward trajectory starting from node i as an element q of the form:
[Equation]
where k j are integers in [ K j ] .
We call T ( i ) the set of such trajectories for node i .
Parameter sets
When X ∈ R
d is ﬁxed, to simplify notations we will often use h iθ to denote h iθ ( X ) .
For p ∈ P of the form p
= ( i, k, s ) , we introduce:
[Equation]
We also denote by ∂S p the boundary of the set S p .
If Q is a subset of P , we use the following notation for convenience:
[Equation]
For a given θ 0 ∈ R m , we deﬁne the set of input vectors X ∈ R d such that h θ 0 is not differentiable:
[Equation]
Consider a random variable X in the input space R d , following the distribution P .
For a given distribution P , we introduce the following set of "critical" parameters:
[Equation]
This is the set of parameters θ where the network is not differentiable for a non-negligible set of datasets X .
Finally, for a given X ∈ R d , we deﬁne the set of parameters for which the network is not differentiable:
[Equation]
Top-level function Also deﬁne a function on the feature space K : R d L → R .
This function might simply be K ( U ) =
U , as in Corollaries 1 and 2.
But it also allows us to represent the kernel function of an MMD GAN in Corollary 3: here we take X to be the two inputs to the kernel stacked together, apply the network to each of the two inputs with the same parameters in parallel, and then compute the kernel value between the two representations with K .
C. A SSUMPTIONS
We will need the following assumptions at various points, where α ≥ 1 :
[Equation]
B
The function K is continuously differentiable, and
satisﬁes the following growth conditions where C 0 and C 1 are constants:
[Equation]
C (Lipschitz nonlinear layers)
For each i ∈ C , f i is M -Lipschitz.
D (Analytic pieces)
For each i ∈ C , there are K i functions ( f ki )
k ∈
[ K i ] that are real analytic on R d π ( i ) which agree with f i on the closure of their domains:
[Equation]
Note that Assumption B is satisﬁed by the function K ( U ) =
U , used in Corollaries 1 and 2, with α = 1 .
It is also satisﬁed by the functions of MMD GAN with each of the kernels we consider in this work; see Corollary 3.
The class of networks we consider here, under Assumptions C and D , includes the vast majority of deep networks used in practice.
For example, most variants of the ReLU activation function as well as max pooling are 1 -Lipschitz, and can be decomposed into linear functions f ki on each ¯ D ki , as discussed previously.
The softmax function as well as most differentiable activation functions, including the logistic sigmoid, tanh , and the ELU (Clevert et al., 2016), also satisfy Assumptions C and D .
C. M AIN RESULTS
We ﬁrst state the main result, which implies Theorem 1 via Corollaries 1 to 3.
The proof depends on various intermediate results which will be established afterwards.
Theorem 4.
Under Assumptions A to D , for µ -almost all θ 0 ∈ R m the function θ (cid:55)→ E P [ K ( h θ
[Equation]
X ))] is differentiable at θ 0 , and
[Equation]
where µ is the Lebesgue measure.
Proof.
Let θ
be in Θ c P , i.e.: θ 0 is such that h θ ( X ) is differentiable in θ 0 for P -almost all X .
Consider a sequence ( θ n ) n ∈ N that converges to θ 0 ; there is then an R > 0 such that (cid:107) θ n − θ 0 (cid:107) <
R for all n ∈ N .
Letting X be in R d , Lemma 2 gives that
[Equation]
with E P [ F ( X )] < ∞ .
It also follows that:
[Equation]
≤ F ( X ) for P -almost all X ∈ R d .
The sequence M n ( X ) deﬁned by:
[Equation]
converges point-wise to 0 and is bounded by the integrable function 2 F ( X ) , therefore by the dominated convergence theorem (Proposition 2) it follows that
[Equation]
Using Lemma 1 and Assumption B to dominate the sequence K ( h θ n ( X )) , we get
[Equation]
K
[Equation]
h
[Equation]
n
[Equation]
E
[Equation] [Equation]
K
[Equation]
h
[Equation]
X
[Equation]
Finally we deﬁne the sequence
[Equation]
which is upper-bounded by E P [ M n ( X )] and therefore converges to 0 .
We have shown that for θ 0 ∈ Θ c P :
[Equation]
But by Proposition 3, µ (Θ P ) = 0 , and so we conclude that this holds for µ -almost all θ 0 in R m .
These corollaries of Theorem 4 apply it to speciﬁc GAN architectures.
Here we use the distribution Z to represent the noise distribution.
Corollary 1 (WGANs) .
Let P and Z be two distributions, on X and Z respectively, each satisfying
Assumption A for α = 1 .
Let G ψ : Z → X be a generator network and D θ : X → R a critic network, each satisfying Assumptions C and D .
Then, for µ -almost all ( θ, ψ ) , we have that
[Equation]
Proof.
By linearity, we only need the following two results:
[Equation]
The ﬁrst follows immediately from Theorem 4, using the function K ( U ) =
U (which clearly satisﬁes Assumption B for α = 1 ).
The latter does as well by considering that the augmented network h ( θ,ψ ) ( Z ) =
D θ ( G ψ ( Z )) still satisifes the conditions of Theorem 4.
Corollary 2 (Original GANs) .
Let P and Z be two distributions, on X and Z respectively, each satisfying Assumption A for α = 1 .
Let G ψ : Z → X be a generator network, and D θ : X → R a discriminator network, each satisfying Assumptions C and D .
Further assume that the output of D is almost surely bounded: there is some γ > 0 such that for µ -almost all ( θ, ψ ) ,
[Equation]
and
[Equation]
Then we have the following:
[Equation]
Thus, by linearity, gradients of all the loss functions given in Goodfellow et al.
(2014, Section 3) are unbiased.
Proof.
The log function is real analytic and ( 1 /γ )-Lipschitz on ( γ, 1 − γ ) .
The claim therefore follows from Theorem 4, using the networks log ◦
D θ , log ◦ [ x (cid:55)→ (1 − x )] ◦ D θ ◦ G ψ , and log ◦ D θ ◦ G ψ with K ( U )
=
U .
The following assumption about a kernel k implies Assumption B when used as a top-level function
K :
E Suppose k is a kernel such that there are constants C 0 , C 1 where
[Equation]
Corollary 3 (MMD GANs) .
Let P and Z be two distributions, on X and Z respectively, each satisfying Assumption A for some α ≥ 1 .
Let k be a kernel satisfying Assumption E .
Let G ψ :
Z → X be a generator network and D θ : X → R a critic representation network each satisfying
Assumptions C and D .
Then
[Equation]
Proof.
Consider the following augmented networks:
[Equation]
h (1) has inputs distributed as P × Z , which satisﬁes Assumption A with the same α as P and Z , and h (1) satisﬁes Assumptions C and D .
The same is true of h (2) and h (3) .
Moreover, the function
[Equation]
satisﬁes Assumption B .
Thus Theorem 4 applies to each of h (1) , h (2) , and h (3) .
Considering the form of MMD 2 u (4), the result follows by linearity and the fact that MMD 2 u is unbiased (Gretton et al., 2012, Lemma 6).
Each of the kernels considered in this paper satisﬁes Assumption E with α at most 2:
• k dot ( x, y )
=
(cid:104)
x, y (cid:105) works with α = 2 , C 0 = 1 , C 1 = 1 .
• k rbf σ of (5) works with α = 2 , C 0 = 1 , C 1 = √ 2 σ − 2 .
• k
rq α (cid:48) of (6) works with α = 2 , C 0 = 1 , C 1 = √ 2 .
• k dist ρ β , 0 of (8), using ρ β ( x, y )
=
(cid:107) x − y (cid:107) β with 1 ≤ β ≤ 2 , works with α = β , C 0 = 3 , C 1 = 4 β .
Since the existence of a moment implies the existence of all lower-order moments by Jensen’s inequality, this ﬁnalizes the proof of Theorem 1.
C. B OUNDS ON NETWORK GROWTH
The following lemmas were used in the proof of Theorem 4.
We start by stating a result on the growth and Lipschitz properties of the network.
Lemma 1.
Under Assumption C , there exist continuous functions θ (cid:55)→ b ( θ ) , a ( θ ) and ( θ, θ (cid:48) )
(cid:55)→ ( α ( θ, θ (cid:48) ) , β ( θ, θ (cid:48) ))
such that:
[Equation]
for all X in R d and all θ, θ (cid:48) in R m .
Proof.
Let X in R d and θ, θ (cid:48) in R m .
We proceed by recursion on the nodes of the network.
For i =
the inequalities hold trivially b 0 = 0 , a 0 = 1 , β 0 =
and α 0 = 0 .
Assume now that:
[Equation]
where a π ( i ) ( θ ) , b π ( i ) ( θ ) , α π ( i ) ( θ, θ (cid:48) ) and β π ( i ) ( θ, θ (cid:48) ) are continuous functions.
If i is a linear layer then:
[Equation]
with a i ( θ ) = (cid:107) g i (cid:107)(cid:107) W i (cid:107) a π ( i ) ( θ ) and b i ( θ ) = (cid:107) g i (cid:107)(cid:107) W i (cid:107) b π ( i ) ( θ ) .
Moreover, we have that:
[Equation]
with:
[Equation]
When i is not a linear layer, then by Assumption C
f i is M − Lipschitz, we get directly the functions by recursion: α i =
Mα π ( i ) , β i =
Mβ π ( i ) , a i =
Ma π ( i ) and b i =
Mb π ( i ) .
Lemma 2.
Let R be a positive constant and θ ∈ R m .
Under Assumptions A to C , the following hold for all θ (cid:48)
∈ B ( θ, R ) and all X in R d :
[Equation]
with E P [ F ( X )] < ∞ .
Proof.
We will ﬁrst prove the following inequality:
[Equation]
for all U and V in R L .
Let t be in [0 , 1] and deﬁne the function f by
[Equation]
Then f (0) =
K ( V ) and f (1) =
K ( U ) .
Moreover, f is differentiable and its derivative is given by:
[Equation]
Using Assumption B one has that:
[Equation]
The conclusion follows using the mean value theorem.
Now choosing U
=
h θ (cid:48)
( X ) and V = h θ ( X ) one gets the following:
[Equation]
Under Assumption C , it follows by Lemma 1 that:
[Equation]
The functions a , b , α , β deﬁned in Lemma 1 are continuous, and hence all bounded on the ball
B ( θ, R ); choose D > 0 to be a bound on all of these functions.
It comes after some algebra:
[Equation]
Set F ( X ) =
C 1 D α
( R + 1) α (1 + (cid:107) X
[Equation]
) α .
Since α ≥ 1 , t (cid:55)→ (1 + t 1 /α )
α is concave on t ≥ 0 , and so we have that
[Equation]
via Jensen’s inequality and Assumption A .
Thus F ( X ) is integrable.
C. C RITICAL PARAMETERS HAVE ZERO MEASURE
The last result required for the proof of Theorem 4 is Proposition 3.
Proposition 3.
Under Assumption D , the set Θ P has 0 Lebesgue measure for any distribution P .
Proof.
We will ﬁrst consider the following two sets:
[Equation]
d |
[Equation]
P and X ∈ N
[Equation] [Equation]
Note that we have the inclusion D ⊆ Q .
We endow the two sets with the product measure ν := µ × P , where µ is the Lebesgue measure.
Therefore ν ( D ) ≤ ν ( Q ) .
On one hand by Fubini’s theorem, we know that:
[Equation]
By Lemma 3, we have that µ (Θ X ) = 0 ; therefore ν ( Q ) =
and hence ν ( D ) = 0 .
On the other hand, we use again Fubini’s theorem for ν ( D ) to write:
[Equation]
If µ (Θ P ) > 0 , it would imply that P ( N ( θ ))
=
for almost all θ ∈ Θ P , which contradicts the deﬁnition of the set Θ P .
We conclude that µ (Θ P ) = 0 .
Lemma 3.
Under Assumption D , for any X in R d , the set Θ X has 0 Lebesgue measure: µ (Θ X ) = 0 .
Proof.
We ﬁrst need to prove that Θ X ⊆ ∂S P .
Let θ
be in Θ X , then by Assumption D , it follows that θ 0 ∈ S P .
Assume for the sake of contradiction that θ 0 / ∈ ∂S P .
Applying Lemma 5 to the output node L , one directly shows that there exist q ∈ T ( L ) and η > 0 such that h θ = h
Lθ = f
q ( θ ) for all θ ∈ B ( θ 0 , η ) , where f q is a real analytic function.
This would mean that the network is differentiable at θ 0 , which contradicts the fact that θ ∈ Θ X .
One can then conclude that Θ X ⊆ ∂S
P , hence, by
Lemma 4, it follows that µ (Θ X ) = 0 .
Lemma 4.
Under Assumption D µ ( ∂S P ) = 0 .
Proof.
We will proceed by recursion.
For i =
we trivially have ∂S ¬ 0 = ∅ , thus µ ( ∂S ¬ 0 )
= 0 .
Assume now that
[Equation]
For some s = ( p, q ) with p ∈ ∂i and q ∈ T ( i ) , deﬁne the set
[Equation]
where f q is a real analytic function deﬁned in Lemma 5 which locally agrees with h π ( i ) θ .
We will prove now that for any θ in ∂S ∂i \ ∂S ¬ π ( i ) there exists s ∈ ∂i × T ( i ) such that θ ∈ M s and µ ( M s )
= 0 .
We proceed by contradiction.
Let θ ∈ ∂S ∂i \ ∂S ¬ π ( i ) , then there exists η >such that B ( θ, η ) ⊆
R m \ ∂S ¬ π ( i ) .
By Lemma 5, there exists q in T ( i ) such that
[Equation]
Moreover, since θ ∈ ∂S ∂i there exists p ∈ ∂i such that G p ( h π ( i ) θ ) = 0 .
This means that for s = ( p, q ) we have θ ∈ M s .
If µ ( M s ) > 0 then by Lemma 6 M s = R m , hence we would have
B ( θ, r ) ⊆
M s .
By Equation (23) it follows that B ( θ, η ) ⊆
S ∂i .
This contradicts the fact that θ is in ∂S ∂i .
We have shown that ∂S ∂i \ ∂S ¬ π ( i ) ⊆
(cid:83) s ∈
A M s , where the sets M s have zero Lebesgue measure and A ⊆ P × (cid:83)
Lj =0 T ( j ) is ﬁnite.
This implies:
[Equation]
Using the recursion assumption µ ( ∂S ¬ π ( i ) )
= 0 , one concludes that µ ( ∂S ¬ i ) = 0 .
Hence for the last node L , recalling that ¬ L = P one gets µ ( ∂S P ) = 0 .
Lemma 5.
Let i be a node in the graph.
Under Assumption D , if θ ∈ R m \ ∂S ¬ i , then there exists η > 0 and q ∈ T ( i ) such that h i θ =
f q ( θ ) on the ball B ( θ, η ) , where f q is real analytic in R m .
Proof.
We proceed by recursion on the nodes of the network.
If i = 0 , we trivially have h 0 θ =
X which is real analytic on R m .
Assume the result for ¬ π ( i ) and let θ ∈
R m \ ∂S ¬ i .
In particular θ ∈ R m \ ∂S ¬ π ( p ) .
By the recursion assumption, we get:
[Equation]
with f q real analytic in R m .
If θ / ∈ S ∂i , then for η small enough B ( θ, η ) is included in the complement of S ∂i , therefore by
Assumption D , there exists k such that h iθ (cid:48) =
f ki ( h
[Equation]
) for all θ (cid:48) ∈ B ( θ, η ) where f ki is real analytic.
By (24) we have:
[Equation]
If θ ∈ S ∂i , then noting that θ / ∈ ∂S ∂i , it follows that for η small enough B ( θ, η ) ⊆
S ∂i .
Denote by
A the set of indices s ∈ ∂i such that θ ∈ S s , therefore θ ∈ (cid:84) s ∈
A S s and θ / ∈ (cid:83) s ∈
A c S s .
We will show that for η small enough B ( θ, η ) ⊆ (cid:84) s ∈
A S s .
By contradiction, there exists a sequence θ n and indices s n such that s n ∈
A c and θ n converges towards θ .
s n has a constant subsequence, so we might assume without loss of generality that s n = s 0 for some s 0 ∈
A c .
Since S s 0 is a closed set by continuity of the network, it follows that θ ∈ S s 0 by taking the limit.
This contradicts the fact that θ / ∈ (cid:83) s ∈
A c S s .
Hence, for η small enough, B ( θ, η ) ⊆
(cid:84) s ∈
A S s .
Again, by Assumption D there exists k satisfying (25).
By setting f q 0 = f ki ( f q ) with q 0 =
(( i, k ) ⊕ q ) , where ⊕ denotes concatenation, it ﬁnally follows that h iθ (cid:48) =
f q 0 ( θ (cid:48) ) for all θ (cid:48) in B ( θ, η ) and f q 0 is real analytic on R m , which concludes the proof.
Lemma 6.
Let θ (cid:55)→ F ( θ ) :
R m → R be a real analytic function on R m and deﬁne the set:
[Equation]
Then either µ ( M ) = 0 or F is identically zero.
Proof.
For a proof of this result, see Proposition 0 of Mityagin (2015).
D M ODEL SAMPLES
Samples from some of the MNIST and CIFAR-10 models are shown in Figure 5 and Figurerespectively.
[Figure] [Figure]
GP samples with size are quite bad more but seem to have