A few weeks ago, Dar lead our discussion of “Learning in Implicit Generative Models” by Mohamed and Lakshminarayanan [1]. This paper gives a good overview of techniques for learning in implicit generative models, and has links to several of the areas we’ve discussed this past year, which I’ll reference throughout.

Learning in Implicit Generative Models

Usually, when thinking of probabilistic methods we think of an explicit parametric specification of the distribution of a random variable , in which we directly specify a log-likelihood with indexing a family of possible distributions. The goal is then to learn from the log-likelihood. In contrast, it is frequently more natural to specify models implicitly via a latent variable which is very easy to generate (e.g multivariate gaussian random variables) which we then transform via a deterministic function , again with indexing a family of such functions.

But why is the problem of learning different here? Namely, it boils down to that the density of can be highly intractable for a number of different reasons. Writing for the density of the latent variable , we have that

where for , if and only if for . Although for certain types of (e.g when it is easily invertible) this integral is tractable, frequently we have scenarios where is non-linear and is specified by a deep network. As mentioned in our discussion, it could be possible to use normalizing flows (which we’ve earlier discussed in the context of variational inference) to allow for this integral to be evaluated in certain circumstances; however if or is not invertible, then we would have to proceed differently. We would then likely encounter several compounding issues:

  • The integration region itself may be very hard to determine.
  • Even if we knew the integration region, the integral itself may then be computationally demanding, depending on the geometry of the integration region, it’s dimension, and the form of the density .
  • Even if we can calculate the integral, we then have to take partial derivatives, which in a high-dimensional scenario is very challenging.

We would therefore like to have a likelihood-free approach to inference, for which there have been various solutions proposed, including generative adversarial networks (GANs) [2] and classifier ABC [3]. We’ve discussed ABC (Approximate Bayesian Computation) before on the blog (see Scott’s blog post from when we discussed a few methods extending it to work in higher dimensions), and GANs have been a frequent reoccuring topic; for a nice quick review of GANs, see the beginning of Robin’s blog post. The contribution of this paper is to discuss and bring together the ideas developed in these methods in unison, where previously they have been isolated to more specialized areas of the literature.

Notation: The data are denoted by a random variable , whose true data density is , with intractable model density . is reserved for model parameters; is used to denote other parameters, such as for discrminator functions.

Likelihood-free inference via density ratios and differences

What are the advantages of generative models? Namely, we can easily draw samples from the model - the latent variables should be chosen so that they can be generated easily, and then we can simply evaluate the function at that point to obtain a draw. Therefore, we should try and use methods which allow for two sets of samples to be compared in order to drive learning. We, for example, can test for whether the true data distribution and the model distribution are equal by directly estimating

  • the density difference , or
  • the density ratio .

As estimating the individual marginal likelihoods will be more difficult than estimating the above ratios/differences directly, which we can then use for comparisons (by seeing how close they are to 0 and 1 respectively), this is therefore an attractive way to proceed. There are (broadly speaking) four general approaches to this problem we could take:

  • class-probability matching,
  • divergence matching,
  • ratio matching, and
  • moment matching

which we’ll discuss in a bit more detail now.

Four general approaches

Class-probability matching - This boils down to using a classifier which can distingush between the observed data and data generated from the model. To describe the general approach, let denote a random variable which assigns label to samples from the true data distribution, and to those from the model distribution, so we can write and . Writing , it therefore follows by Bayes’ formula that

and so estimating the density ratio is equivalent to that of class-probability estimation, as we now only need to compute .

We now need to specify a scoring function or discriminator depending on some parameters , which is linked to the density ratio via the mapping . This means we can use tools for building classifiers (e.g deep neural networks) to specify these functions. Given a scoring function, we now need to specify a proper scoring rule in order to learn parameters. Choosing a Bernoulli (logarithmic) loss, it follows that we can arrive at equation 5 of the paper, namely the GAN objective

which we then try and minimize by bi-level optimization. Of course, we can use other scoring rules if desired, with the overall strategy remaining the same.

Divergence minimization - Here the idea is to try and use a divergence between and in order to drive learning. One class of divergences is the -divergence, which for a convex function is of the form

If these seem completely foreign to you, then note that by the following choices of , we can obtain some more familar measures of distance:

  • the KL-divergence -
  • the total variation distance -
  • the divergence -
  • the Jensen-Shannon divergence -

Writing for the derivative of and for the Fenchel conjugate (or convex dual), this is lower bounded by

The optimum is related to the density ratio via , and so by substituting in this to the above formula, it is equivalent to the following minimization problem in

which we can again optimize via bi-level optimization. Here there is no discriminator persay, with its role taken by the ratio function itself. We note that if we let , then we again obtain the original GAN objective; the paper on f-GANs by Nowizin et al. [4] discusses this approach further. As mentioned by the authors, there is also an equivalence between this and class probability estimation.

Ratio matching - Writing the true density ratio as and allowing to be an approxiation parameterized by , we could consider the loss

which can be generalized to trying to minimize the Bregman divergence for a given function . Although we’ll encounter the Bregman divergence later (including its definition), for now we’ll simply remark that one can show

where is the same ratio loss as that for divergence minimization above. However, as the divergence term is dependent on , which is unknown, we could consider an approximation where e.g the ratio is near-optimal, in which case , with the corresponding approximate loss then used for learning.

Moment matching - One last technique is to try and use the fact that and are identical if and only if the expectations of any test statistic are identical under both laws, and so we try and minimize the gap

Here the choice of is very important to the performance of the procedure, as ideally we would like all the moments of the distributions to be matched. If the functions belong to a reproducing kernel Hilbert space , this objective can then be reformulated to give

where is some function space, giving rise to the maximum mean discrepancy. We can then generalize this to other integral probability metrics, such as the Wasserstein distance, which is used in Wasserstein GANs. In addition, ABC also generally uses a moment matching approach to learning for these types of generative models.


To conclude, although the choice of whether we implicitly define or prescribe our model affects the type of learning and inferential procedures we can use, the authors highlight that

“Any implicit model can be easily turned into a prescribed model by adding a simple likelihood function on the generated outputs, so the distinction is not essential”.

As a consequence, it is important to distingush between the choice of model, the choice of inference and the resulting choice of algorithms; within this, it is perhaps worth noting e.g GANs come under only this third umbrella, and there are other algorithms out there.


[1] Mohamed, Shakir, and Balaji Lakshminarayanan. “Learning in Implicit Generative Models.” arXiv preprint arXiv:1610.03483 (2016). link

[2] Goodfellow, Ian, et al. “Generative adversarial nets.” Neural Information Processing Systems (NIPS) (2014). link

[3] M. U. Gutmann, R. Dutta, S. Kaski, and J. Corander. “Statistical inference of intractable generative models via classification”. arXiv preprint arXiv:1407.4981, 2014. link

[4] Nowozin, Sebastian, Botond Cseke, and Ryota Tomioka. “f-GAN: Training Generative Neural Samplers using Variational Divergence Minimization.” Neural Information Processing Systems (NIPS) (2016). link


  1. Strictly, only the total variation distance is actually a metric; infact, one can show that it is the only -divergence (up to scaling) which gives rise to a proper metric.
  2. Having had a quick look, I’m unsure on whether this is something which would be practically useful; it could be interesting to give this a further look for whether it is the case.