I recently worked on an applied project involving Mixture Density Networks (MDNs), and it got me pondering them more from the statistical perspective. Most of the papers on MDNs are based around computational approaches or application. I also haven’t actually used this blog for any blog posts, so I wanted to get something out there and maybe start a pattern of contributing more regularly.
MDNs were proposed by Christopher Bishop in a 1994 technical report, and they have gained traction recently as a number of modern software packages became capable of efficiently implementing them. tensorflow/tensorflow-probability and pytorch/pyro are two examples of package pairs where the shared infrastructure allows welding together of probabilistic elements with neural networks and algorithmic differentiation in a cohesive fashion, and using these tools permits relatively easy implementation of the MDN concept. A quick Google Scholar search yields many results on applications of MDNs in problems ranging from climate science to robotics.
The basic concept of a MDN is that, instead of using of using a neural network to deterministically predict the output, you use the network to predict the parameters of a distribution over the output, and then maximize the likelihood of the weights of the network with respect to the distribution over the data. That is, instead of estimating the weights of the network in an attempt to estimate the function , we try to estimate a function to satisfy
where
for some parameterized distribution
with
and
. Typically
is modeled as a K-fold mixture distribution, where a component of
corresponds to the mixing coefficients and
has
dimensions corresponding to the
simplex.
The way inference is typically done is to maximize the log likelihood as a function of the weights of the network. That is, for any network architecture with weights in some weight space
, for some
which is a function of the architecture of the network, we are minimizing:
Where is the density of the distribution
.
Let denote
and suppose that:
where is some distribution that has density
. Factorizing
into
, and using the MDN model to approximate
with
:
The Law of Large Numbers gives us that, as :
We also have that, because is independent of
, and assuming
exists:
Now note that doesn’t depend on
, so we can add it to the previous limit to give us:
Rearranging a bit by putting the two logs together, and using the fact that , we get:
Which is the Kullback-Leibler Divergence between and the distribution
with density
. This gives us that the MDN model converges in probability to the Kullback-Leibler projection of
onto
.
Breaking this apart a little bit, note that if the family is sufficiently robust such that
we have that, using the fact that the total variation distance is bounded above by the square root of one half of the Kullback-Leibler divergence, in the limit
for all measurable sets
; where the probability is taken over
. Another important fact is that there are no requirements placed on the space
.
must be a subset of
for some
to make it a typical neural network architecture, but
could be a more general probability space and the limiting result would still hold. Two important special cases are when
is discrete or matrix valued.
Noting that we can remove the terms inside the log, we can obtain:
Using properties of conditional expectations we get:
So the term inside is the KL divergence between the distribution with density and the distribution with density
for given
. The outer expectation is the expectation with respect to the marginal distribution on the
. This gives another interpretation of the limiting solution
; it’s the solution that minimizes the Kullback-Leibler divergence between the true conditional distribution and the MDN for a particular
, averaged over the true distribution of the
.
There are some problems with the calculations done previously, mainly some identifiability assumptions. The previous outline is mostly following along inline with Theorem 2.1 and 2.2 of a 1982 paper by Halbert White titled Maximum Likelihood Estimation in Misspecified Models in Econometrica. The primary assumptions we need are from A3 in that paper:
-
needs to exist and
for every
where
is integrable with respect to
.
has a unique minimum in
.
- To incorporate the fact that the results in the previously referenced paper didn’t have the conditional distribution component, we also need the assumption that
exists.
The assumptions on and
are hard to verify when building the model, as they represent the unknown true distribution, but correspond to the joint and marginal entropy of
. The assumption
is easier to validate, as we have knowledge about the structure of
. The 2nd assumption regards identifiability, and this is generally not true for MDNs as the mixture component is only identifiable up to permutation. One can remedy this by enforcing an ordering on the mixing coefficients, but there might still be identifiability issues of the weights in the network component.
There’s also some possibilities of calculating the asymptotic distributions of the weights given some additional assumptions outlined in the previously referenced paper. Most of the results should still apply with some additional requirements; as we’re approximating the conditional distribution using the MDN and not the full joint distribution of the data . An interesting thing to consider with the asymptotic distributions is that they’re likely to depend on the Fisher information in some way, and with the automatic differentation capabilities of tensorflow and pytorch you might be able to approximate the matrix of second derivatives accurately using numerical methods.
I was really interested in MDNs when I first heard about them. I think analyzing them from this perspective gives insight into how to build models with desirable asymptotic properties, and even the entropy assumptions on illustrate that for particularly unwieldy underlying distributions, the asymptotic may not apply.
Thanks to Anar Yusifov for introducing me to MDNs, and for many insightful discussions on the topic.

Leave a Reply