Post · 7 min read· pp. 62–65

Another Favourite Machine Learning Paper: Adversarial Networks vs Kernel Scoring Rules

A while ago I wrote a post on my then-current favourite machine learning paper which connected denoising autoencoders to pseudolikelihood learning. I am generally intrigued by papers that establish connections between seemingly unrelated techniques, thereby bringing communities and frameworks together. Today I have found a similarly interesting paper from my old lab in Cambridge. In fact, there are two papers with the authors inventing pretty much the same thing in parallel:

Unsupervised Learning with Deep Models

Deep learning has achieved several breakthroughs in supervised learning, setting new benchmarks in speech, computer vision and natural language understanding. Many agree that one of the most interesting frontiers of research in this area is unsupervised learning: how do we learn rich, deep, distributed representations of data, when labels are not provided?

In unsupervised learning we are given indepenent samples xix_i from some underlying data distribution PP, and our goal is to come up with an approximate distribution QQ that is as close to PP as possible, only using the samples xix_i. Often, QQ is chosen from a parametric family of distributions {Q(⋅;θ),θ∈Θ}\{Q(\cdot ;\theta),\theta\in\Theta\}, and our goal is to find the optimal parameters θ∗\theta^{\ast} so that the distribution PP is best approximated.

The central issue of unsupervised learning is choosing an appropriate objective function ℓ(θ,P)\ell(\theta,P), that appropriately measures the quality of our approximation, and which is tractable to compute and optimise when we are working with complicated, deep models. The most straightforward choice, marginal likelihood, is intractable in most cases, and researchers over the past decades have come up with a zoo of methods, such as contrastive divergence, pseudolikelihood and variational bounds, to solve this problem. Bt largely, people agree that unsupervised learning in deep generative models is far from solved.

Here, I'm writing about a promising new objective function used in Adversarial Generative Networks, and its connection to Maximum Mean Discrepancy which is known from the kernel machines literature.

Generative Adversarial Networks

Generative Adversarial Networks (GANs) are intuitively described as a game or fight between two neural networks: a generative model that specifies how to generate samples from the approximate distribution QQ, and a discriminative network that tries to distinguish samples generated by the generative network from real data. The goal is that over time both the generative and discriminative models get better at their tasks, so we are left with a generative model whose samples the best discriminative network had a hard time distinguishing from real data.

Mathematically, the procedure minimises the following objective function:

ℓ(θ,P)=max⁡ψEx∼Q(⋅;θ)log⁡ f(x;ψ)+Ex∼Plog⁡(1−f(x;ψ))\ell(\theta,P) = \max_{\psi} E_{x\sim Q(\cdot;\theta)} \log~f(x; \psi) + E_{x\sim P} \log(1 - f(x; \psi))

Explanation of terms:

  • PP is the true data distribution, in this case PP will be approximated as the empirical distribution of data points.
  • Q(⋅;θ)Q(\cdot; \theta) is a probability distribution over xx, parametrised by θ\theta. I will call this the approximate distribution. In original paper QQ was described as a generative procedure whereby a low dimensional latent vector zz was drawn from some simple parametric distribution, and then zz was transformed nonlinearly to obtain xx by a neural network whose parameters are θ\theta.
  • f(x;ψ)f(x; \psi) is a parametric discriminative function taking values between 0 and 1 and parametrised by ψ\psi. It takes an input xx and predicts whether xx was a sample from the true data distribution PP or the approximate distribution QQ. In this work, ff is modelled as a deep neural network trained in a supervised way.
  • the first term Ex∼Q(⋅;θ)log⁡ f(x;ψ)E_{x\sim Q(\cdot;\theta)} \log~f(x; \psi) encourages the discriminative function ff to give a positive (f(x)=1f(x)=1) output for any sample from QQ while the second term Ex∼Plog⁡(1−f(x;ψ))E_{x\sim P} \log(1 - f(x; \psi)) encourages it to give a negative output (f(x)=0f(x)=0) for samples in P. If the function ff is a perfect discriminator with respect to QQ and PP, the sum of these two terms is 0, otherwise it's negative.

The core of the idea is to train a probabilistic model Q(⋅;θ)Q(\cdot; \theta) in such a way that the best possible discriminator function ff cannot differentiate well between QQ and the true data distribution PP. This is not the first time I see this idea! - I thought. Maximum mean discrepancy also tries to do exactly this.

Maximum Mean Discrepancy

Maximum mean discrepancy(MMD) was originally proposed by the kernel machines community as a nonparametric way to measure dissimilarity between two probability distributions. It's worth pointing out it has also been independently discovered as kernel scoring rule in statistics.

Just like any metric of dissimilarity between distributions, MMD can be used as an objective function for generative modelling, and this is exactly what the paper I found today proposed to do. Have a look at the MDD objective, and observe the similarities to the adversarial objective above:

ℓ(θ,P)=MMD(Q(⋅;θ),P)=sup⁡f∼F∣Ex∼Pf(x)−Ex∼Qf(x)∣\ell(\theta,P) = MMD(Q(\cdot; \theta),P) = \sup_{f\sim \mathcal{F}} \left\vert E_{x\sim P}f(x) - E_{x\sim Q}f(x)\right\vert

The MMD criterion also uses the concept of an 'adversarial' function ff that discriminates between samples from QQ and PP. However, instead of it being a binary classifier constrained to predict 0 or 1, here ff can be any function chosen from some function class F\mathcal{F}. The discrimination is measured not in terms of binary classification accuracy as above, but as the difference between the expected value of ff under PP and QQ. The idea is: if PP and QQ are exactly the same, there should be no function whose expectations differ under QQ and PP.

In adversarial networks, the maximisation over ff was carried out via stochastic gradient descent, here it can be done analytically, under suitable assumptions. It turns out that if the function class F\mathcal{F} is (the unit ball of) a reproducing kernel Hilbert space characterised by kernel kk, the maximisation can be carried out analytically, and we obtain the following expression after applying the kernel trick:

MMDk(Q,P)=Ex,x′∼P,Pk(x,x′)+Ex,x′∼Q,Qk(x,x′)−2Ex,x′∼P,Qk(x,x′)MMD_k(Q,P) = E_{x,x' \sim P,P}k(x,x') + E_{x,x' \sim Q,Q}k(x,x') - 2 E_{x,x' \sim P,Q}k(x,x')

In the expression above

  • Ex,x′∼P,Pk(x,x′)E_{x,x' \sim P,P}k(x,x') is constant with respect to Q, so we can just drop it from the objective.
  • the second term Ex,x′∼Q,Qk(x,x′)E_{x,x' \sim Q,Q}k(x,x') can be interpreted as an entropy term: minimising this will force Q to be spread out, rather than concentrate on a single set of points
  • the third term Ex,x′∼P,Qk(x,x′)E_{x,x' \sim P,Q}k(x,x') ensures that samples from QQ are on average close to samples from PP

Pros and cons of each approach

  1. kernel MDD is strictly proper: When designing loss functions for unsupervised learning, an important to check whether the loss function is a strictly proper scoring rule or not. Roughly speaking, being strictly proper means that the objective function can't be easily tricked. We know that both maximum likelihood learning and pseudo-likelihood learning possess this property, and this ensures that they result in statistically consistent learning algorithms. Kernel MMD has been shown to be strictly proper depending on the choice of kernel function. However, it is unlikely that the adversarial network objective is strictly proper without further restrictions.
  2. adversarial network might overfit: The discriminative adversarial network ff can overfit the training data, if not properly regularised. For example, it can learn to memorise all data points from PP, now making it very easy to discriminate between any QQ and PP. In kernel MMD, regularisation is part of the definition of the loss function, so one does not have to worry that much about overfitting.
  3. deep neural networks are superior discriminative models: MMD uses functions from a kernel Hilbert space as discriminatory functions. We know from recent success that deep neural networks are probably superior discriminative models in high-dimensional data such as natural images.
  4. adversarial networks are easier to generalise: because application of the kernel trick relies on the particular form of the MMD objective function, it is very hard to generalise the MMD objective to make it more performant. On the other hand one can imagine alternative adversarial network objectives based on ROC curves or f-scores, which may perform better than the original criterion.
  5. the two can be combined: One could design a kernel which has a deep neural network in it, and use the MMD objective with that kernel for a hybrid method. Not sure if this would make sense, but why not :)