{'fraction_non_alphanumeric': 0.05050204978907968, 'fraction_numerical': 0.01334838492464302, 'mean_word_length': 4.531770376862402, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
MIM: Mutual Information Machine

We introduce the Mutual Information Machine (MIM), a probabilistic auto-encoder for learning joint distributions over observations and latent variables. MIM reflects three design principles: 1) low divergence, to encourage the encoder and decoder to learn consistent factorizations of the same underlying distribution; 2) high mutual information, to encourage an informative relation between data and latent variables; and 3) low marginal entropy, or compression, which tends to encourage clustered latent representations. We show that a combination of the Jensen-Shannon divergence and the joint entropy of the encoding and decoding distributions satisfies these criteria, and admits a tractable cross-entropy bound that can be optimized directly with Monte Carlo and stochastic gradient descent. We contrast MIM learning with maximum likelihood and VAEs. Experiments show that MIM learns representations with high mutual information, consistent encoding and decoding distributions, effective latent clustering, and data log likelihood comparable to VAE, while avoiding posterior collapse.


Introduction
Latent Variable Models (LVMs) are probabilistic models that enhance the distribution over observations into a joint distribution over observations and latent variables, with VAE (Kingma & Welling, 2013) being a canonical example. It is hoped that the learned representation will capture salient information in the observations, which in turn can be used in downstream tasks (e.g., classification, inference, generation). In addition, a fixed-size representation enables comparisons of observations with variable size (e.g., time series). The VAE popularity stems, in part, from its versatility, serving as a generative model, a probability density estimator, and a representation learning framework. Mutual information (MI) is often considered a useful measure of the quality of a latent representation (e.g., (Hjelm et al., 2019;Belghazi et al., 2018;Chen et al., 2016a)). Indeed, many common generative LVMs can be seen as optimizing an objective involving a sum of mutual information terms and a divergence between encoding and decoding distributions (Zhao et al., 2018). These include the VAE (Kingma & Welling, 2013), β-VAE (Higgins et al., 2017), andInfoVAE (Zhao et al., 2017), as well as GAN models including ALI/BiGAN (Dumoulin et al., 2017;Donahue et al., 2016), InfoGAN (Chen et al., 2016a), and Cycle- GAN (Zhu et al., 2017). From an optimization perspective, however, different objectives can be challenging, as MI is notoriously difficult to estimate (Belghazi et al., 2018), and many choices of divergence require adversarial training.
In this paper, we introduce a class of generative LVMs over data x and latent variables z called the Mutual Information Machine (MIM). The learning objective for MIM is designed around three fundamental principles, namely 1. Consistency of encoding and decoding distributions; 2. High mutual information between x and z; 3. Low marginal entropy.
Consistency enables one to both generate data and infer latent variables from the same underlying joint distribution (Dumoulin et al., 2017;Donahue et al., 2016;Pu et al., 2017). High MI ensures that the latent variables accurately capture the factors of variation in the data. Beyond consistency and mutual information, our third criterion ensures that each distribution efficiently encodes the required information, and does not also model spurious correlations.
MIM is formulated using 1) the Jensen-Shannon divergence (JSD), a symmetric divergence that also forms the basis of ALI/BiGANs and ALICE, (Dumoulin et al., 2017;Donahue et al., 2016;Li et al., 2017), and 2) the entropy of the encoding and decoding distributions, encouraging high mutual information and low marginal entropy. We show that the sum of these two terms reduces to the entropy of the mixture of the encoding and decoding distributions defined by the JSD. Adding parameterized priors, we obtain a novel upper bound on this entropy, which forms the MIM objective. Importantly, the resulting cross-entropy objective enables direct optimization using stochastic gradients with reparameterization, thereby avoiding the need for adversarial training and the estimation of mutual information. MIM learning is stable and robust, yielding consistent encoding and decoding distributions while avoiding over-and underestimation of marginals (cf. (Pu et al., 2017)), and avoiding posterior collapse in the conventional VAE.
We provide an analysis of the MIM objective and further broaden the MIM framework, exploring different sampling distributions and forms of consistency. We also demonstrate the benefits of MIM when compared to VAEs experimentally, showing that MIM in particular benefits greatly from more expressive model architectures by utilizing the additional capacity for better representation (i.e., compressed representation with higher mutual information).

Generative LVMs
We consider the class of generative latent variable models (LVMs) over data x ∈ X and latent variables z ∈ Z. These models generally assume an explicit prior over latent variables, P(z), and an unknown distribution over data, P(x), specified implicitly through data examples. As these distributions are fixed and not learned, we call them anchors. The joint distribution over x and z is typically expressed in terms of an encoding distribution, q θ (z | x) P(x), or a decoding distribution p θ (x | z) P(z), where q θ (z | x) and p θ (x | z) are known as the encoder and decoder. Zhao et al. (2018) describe a learning objective that succinctly encapsulates many LVMs proposed to date, L(θ) = α 1 I q (x; z) + α 2 I p (x; z) + λ D . (1) where θ comprises the model parameters, α 1 , α 2 , λ are weights, D is a set of divergences, and I q (x; z) and I p (x, z) represent mutual information under the encoding and decoding distributions. The divergences measure inconsistency between the encoding and decoding distributions. By encouraging high MI one hopes to learn meaningful relations between x and z (Higgins et al., 2017;Zhao et al., 2017;Chen et al., 2016a;Zhu et al., 2017;Li et al., 2017).
One of the best-known examples within this framework is the variational auto-encoder (VAE) (Kingma & Welling, 2013;Rezende et al., 2014), which sets α 1 = α 2 = 0, λ = 1, and the divergence D to D KL (q θ (z | x) P(x) p θ (x | z) P(z)) . (2) One can show that this objective is equivalent, up to an additive constant, to the evidence lower bound typically used to specify VAEs. Although widely used, two issues can arise when training a VAE. First, the asymmetry of the KL divergence can lead it to assign high probability to unlikely regions of the data distribution (Pu et al., 2017). Second, it sometimes learns an encoder that essentially ignores the input data and instead models the latent prior. This is known as posterior collapse. The consequence is that latent states convey little useful information about observations.
Another example is the ALI/BiGAN model (Dumoulin et al., 2017;Donahue et al., 2016), which is instead defined by the Jensen-Shannon divergence: where M S is an equally weighted mixture of the encoding and decoding distributions; i.e., The symmetry in the objective helps to keep the marginal distributions consistent, as with the symmetric KL objective used in (Pu et al., 2017).
As described by Zhao et al. (2018), many such methods belong to a difficult class of objectives that usually rely on adversarial training, which can be unstable. In what follows we show how by further encouraging low marginal entropy, and with a particular combination of MI and divergence, we obtain a framework that accomplishes many of the aims of the previous methods while also allowing for stochastic gradient-based optimization.

Symmetry and Joint Entropy
We begin with an objective that satisfies our desiderata of symmetry, high mutual information, and low marginal entropy, i.e., the sum of D JS in (3) and R H , defined by Here, H q (x, z) is the joint entropy under the encoding distribution, which can also be expressed as H q (x) + H q (z) − I q (x; z), the sum of marginal entropies w.r.t. x and z minus their mutual information. Analogously, H p (x, z) is the joint entropy under the decoding distribution. Note that if symmetry is ever achieved, i.e., D JS = 0, then the marginal entropy terms become constant and R H directly targets mutual information. This is unlikely to happen in practice, but would roughly hold for small divergence values.
The objective D JS + R H encourages consistency through the JSD, and high MI and low marginal entropy through R H . Interestingly, one can also show that this specific combination of objective terms reduces to the entropy of the mixture distribution M S ; i.e., While H M S (x, z) is intractable to compute, as it contains the unknown P(x) in the log term, it does suggest the existence of a tractable upper bound that can be optimized straightforwardly with stochastic gradients and reparameterization (Kingma & Welling, 2013;Rezende et al., 2014). This bound, introduced below, forms the MIM objective.

The MIM Objective
Section 3.1 formulates a loss function (6) that reflects our desire for a consistent and expressive model, however direct optimization is intractable. Adversarial optimization is feasible, however it can also be unstable. As an alternative, we introduce parameterized approximate priors, q θ (x) and p θ (z), to derive a tractable upper-bound. This is similar in spirit to VAEs, which introduce a parameterized approximate posterior. These parameterized priors, together with the encoder and decoder, q θ (z|x) and p θ (x|z), comprise a new pair of joint distributions, These new joint distributions allow us to bound (6); i.e., where CE ( M S , M θ ) denotes the cross-entropy between M S and M θ , and M θ = 1 2 (p θ (x, z) + q θ (x, z)). This cross-entropy loss aims to match the model prior distributions to the anchors, while also minimizing H M S (x, z). Importantly, it can be trained by Monte Carlo sampling from the anchor distributions with reparameterization.
The penalty we pay in exchange for stable optimization is the need to specify prior distributions q θ (x) and p θ (z). We could set p θ (z) = P(z), though allowing it to vary provides more flexibility to minimize other aspects of the objective. We do not have a closed form expression for P(x), however q θ (x) can be any data likelihood model, i.e., a normalizing flow (Dinh et al., 2014;2016;Rezende & Mohamed, 2015), an auto-regressive model (Larochelle & Murray, 2011;Van den Oord et al., 2016), or even as an implicit distribution (see Section 4.2). In this paper, for fair comparison with a VAE, we use an implicit distribution. In this way, MIM has the same set of parameters as the corresponding VAE, and they only differ in their respective loss functions. The use of an auxiliary likelihood model has been explored in other contexts, e.g., the noise distribution in noise contrastive estimation (Gutmann & Hyvärinen, 2010).
While L CE encourages consistency between model and anchored distributions, i.e., p θ (x, z) ≈ p θ (x|z)P(z) and q θ (x, z) ≈ q θ (z|x)P(x), it does not directly encourage model consistency, p θ (x, z) ≈ q θ (x, z). To remedy this, we upper-bound L CE using Jensen's inequality to obtain the MIM loss, L MIM ≥ L CE , where The loss for the Mutual Information Machine is an average of cross entropy terms between the mixture M S and the model encoding and decoding distributions. To see that this encourages model consistency, it can be shown that L MIM is equal to L CE plus a non-negative regularizer: where, as shown in supplementary material, One can conclude from (10) that the regularizer R MIM is zero only when the two model distributions, q θ (x, z) and p θ (x, z), are identical under fair samples from the joint sample distribution M S (x, z). In practice we find that encouraging model consistency also helps stabilize learning.
To understand the MIM objective in greater depth, it is helpful to express L MIM as a sum of fundamental terms that provide intuition for its behavior. i.e., one can show that: The first term in Eqn. (11) encourages high mutual information between observations and latent states. The second shows that MIM directly encourages the model priors to match the anchor distributions. Indeed, the KL term between the data anchor and the model prior is the maximum likelihood objective. The third term encourages consistency between model and anchored distributions, in effect fitting the model decoder to samples drawn from the anchored encoder (cf. VAE), and, via symmetry, fitting the model encoder to samples drawn from the anchored decoder (both with reparameterization). As such, MIM can be seen as simultaneously training and distilling a model distribution over the data into a latent variable model. The idea of distilling density models has been used in other domains, e.g., for parallelizing auto-regressive models (Oord et al., 2017).

Asymmetric Mutual Information Machine
With some models, like auto-regressive distributions (e.g., PixelHVAE (Tomczak & Welling, 2017)), sampling from p θ (x | z) becomes impractical during learning. This is problematic for MIM, as it draws samples from M S , a mixture of the anchored encoding and decoding distributions.
As an alternative, we introduce a variant of MIM, called A-MIM, that only samples from the encoding distribution.
To that end, collecting terms in Eqn. (11) which depend on samples from q θ (z | x) P(x), we obtain where M q S = q θ (z | x) P(x). Minimization of L A-MIM (θ) learns a consistent encoder-decoder model with an encoding distribution with high mutual information and low entropy. Formally, one can derive the following bound: where the gap between L A-MIM and the cross-entropy term has the same form as R MIM in Eqn. (10), but with M S replaced by M q S . It is still 0 when q θ (x, z) = p θ (x, z). The main difference between MIM and A-MIM is the lack of symmetry in the sampling distribution. This is similar to the VAE formulation in Eqn. (2). Indeed, the final term in Eqn. (13) is exactly the VAE loss, with an optionally parameterized latent prior p θ (z). Importantly, q θ (x) must be defined implicitly using the marginal of the decoding distribution, otherwise it will be completely independent from the other terms. Without this, A-MIM can be seen as a VAE with a joint entropy penalty, and we have found that this doesn't work as well in practice.
In essence, A-MIM trades symmetry of the JSD for speed. Regardless, we show that A-MIM is often as effective as MIM at learning representations.

A-MIM, VAEs, and Posterior Collapse
The VAE loss in Eqn. (2) can be expressed in a form that bears similarity to the A-MIM loss in Eqn. (12) (details in the supplementary material); i.e., Like L A-MIM in Eqn. (12), the first term in Eqn. (15) is the average of two cross-entropy terms between a sample distribution and the encoding and decoding distributions. Like L A-MIM , here they are asymmetric, as samples are drawn

Algorithm 1 MIM learning of parameters θ
Require: Samples from anchors P(x), P(z) 1: while not converged do 2:

Standard MIM Learning
Here we provide a detailed description of MIM learning. The training procedure is summarized in Algorithm 1. It is very similar to training a VAE; gradients are taken by sampling using the reparameterization trick (Kingma & Welling, 2013;Rezende et al., 2014).

Learning with Marginal q θ (x)
When we would like to use a marginal data prior, we must modify the learning algorithm slightly. This is because the MIM objective in Equation (8) involves a log q θ (x) term, and the marginal is intractable to compute analytically. Instead we minimize an upper bound on the necessary integrals using Jensen's inequality. Complete details of the derivations are given below.
For the encoder portion of M S , the integral can be bounded and approximated as follows.
Similarly, the decoder portion can be bounded and approxi-Algorithm 2 MIM learning with marginal q θ (x) Require: Samples from anchors P(x), P(z), q θ (z | x) In both cases, we use importance sampling from q θ (z | x). The full algorithm, collecting all like terms, is summarized in Algorithm 2.

Experiments
We next examine MIM empirically, often with a VAE baseline. We use both synthetic datasets and well-known image datasets, namely MNIST (LeCun et al., 1998), Fashion-MNIST (Xiao et al., 2017 and Omniglot (Lake et al., 2015). All models were trained using Adam (Kingma & Ba, 2014) with a learning rate of 10 −3 , and a mini-batch size of 128. Following (Alemi et al., 2017) we stabilize training by increasing the weight on the second (decoder) CE term in Eqn.
(8), from 0 to 0.5, in several 'warm-up' epochs. Training continues until the loss, Eqn. (8), on a held-out validation set has not improved for the same number of epochs as the warm-up steps (i.e., defined per experiment). The number of epochs to convergence of MIM learning is usually 2 to 5 times greater than a VAE with the same architecture. A more complete description of MIM learning is provided in the supplementary material.

Synthetic Data
As a simple demonstration, Fig. 1 depicts models learned on synthetic 2D data, x ∈ R 2 , with a 2D latent space, z ∈ R 2 .
In 2D one can easily visualize the model and measure quantitative properties of interest (e.g., mutual information). Here, P(x) is a Gaussian mixture model comprising five isotropic components with standard deviation 0.25 ( Fig. 1 top), and P(z) is an isotropic standard Normal distribution ( Fig. 1  bottom). The encoder and decoder have two fully connected layers with tanh activations, and output the mean and variance of Gaussian densities. The parameterized prior, q θ (x), is defined to be the marginal of the decoding distribution (see Section 4.2) and the model prior p θ (z) is defined to be P(z). That is, the the only model parameters are those of the encoder and decoder. We can therefore learn with MIM and VAE models using the same architecture and parameterization. The warm-up comprises 3 steps ( As functions of the number of hidden units, Fig. 2 shows MI and average test negative log-likelihood (NLL) under the encoder, the test RMS reconstruction error, and 5-NN classification performance, predicting the GMM component responsible for each test point. Performance on the auxiliary classification task is a proxy for representation quality. Mutual information, reconstruction RMSE, and classification accuracy for test data are all as good or better with MIM, at the expense of poorer NLL.
Low-dimensional Image Data: We next consider data obtained by projecting 784D Fashion-MNIST images onto a 20D linear subspace (capturing 78.5% of total variance), at which we can still reliably estimate MI. The training and validation sets had 50,000 and 10,000 images. Fig. 3 plots results as a function of the demension of the latent space z. MIM yields high MI and good classification accuracy at all but very low latent dimensions. MIM and VAE yield similar test reconstruction errors, with VAE having better NLL for test data. Again VAE is prone to posterior collapse and low MI for more expressive models. In contrast, MIM is robust to posterior collapse. This is consistent with Eqn. (15) and results of Zhao et al. (2018) showing that many VAE variants designed to avoid posterior collapse are essentially encouraging higher MI.

MIM Learning with Image Data
We next consider MIM and VAE learning with three image datasets, namely, Fashion-MNIST, MNIST, and Omniglot. Unfortunately, with high dimensional data we cannot reliably compute MI (Belghazi et al., 2018). Instead, for model assessment we focus on NLL, reconstruction errors, and the quality of random samples. In doing so we also explore multiple, more expressive architectures, including the top performing models from (Tomczak & Welling, 2017), namely, convHVAE (L = 2) and PixelHVAE (L = 2), with Standard (S) priors 1 , and VampPrior (VP) priors 2 . The VP 1 p θ (z) = N (z; µ = 0, σ = I), a standard Normal distribution, where I is the identity matrix.
2 p θ (z) = 1 K K k=1 q θ (z|u k ), a mixture model of the encoder posterior with optimized pseudo-inputs u k .  pseudo-inputs are initialized with training data samples. For all experiments we use the experimental setup described by Tomczak & Welling (2017), and the same latent dimensionality, i.e., z ∈ R 80 . Finally, in the case of auto-regressive decoders (e.g., PixelHVAE), because sampling is extremely slow, we use A-MIM learning instead of MIM. Table 4 reports NLLs on test data. As above, one can see that VAEs tend to yield better NLL scores. However, the gap becomes narrower for the more expressive PixelHVAE (S) and largely closes for the most expressive PixelHVAE (VP). As the model capacity increases, we have found thatMIM tends to better utilize the additional modelling power.
We also show qualitative results for the more expressive PixelHVAE (VP) models. Fig. 5  The poor NLL and hence poor sampling for MIM when specified with a weak prior model can be explained by the tightly clustered latent representation that MIM often learns (e.g., Fig. 1). A more expressive, parameterized prior such as the VampPrior can capture such clusters more accurately, and produce better samples. To summarize, while VAE opts for better NLL and sampling, at the expense of lower mutual information, MIM provides higher mutual information at the expense of the NLL for a weak prior, and comparable NLL and sampling with more expressive priors.

Clustering and Classification
Finally, following (Hjelm et al., 2019), we consider an auxiliary classification task as a further measure of the quality of the learned representations. We use k-nearest-neighbor (K-NN) classification as it is simple, non-parametric method that relies on a suitable arrangement of the latent space. We experimented with different neighborhood sizes of 1,3, 5 and 10, but all gave comparable results. We therefore applied a 5-NN classifier to the representations learned in Sec. 5.2 on test samples from MNIST and Fashion-MNIST. Table 6 shows that MIM yields more accurate classification results in all but one case. We attribute the performance difference to higher mutual information of MIM representations. Figures 7 and 8 provide qualitative visualizations of the latent clustering, for which t-SNE (van der Maaten & Hinton, 2008)) was used to project the latent space down to 2D. One can see that MIM learning tends to cluster classes in the latent representation more tightly, while VAE clusters are more diffuse and overlapping, consistent with the results in Table 6.

Related Work
Zhao et al. (2018) establishes a unifying objective that describes many common VAE variants. They show that these variants optimize the Lagrangian dual of a primal optimization problem involving mutual information, subject to constraints on a chosen divergence. They use this to directly optimize the Lagrange multipliers and explore the pareto front of mutual information maximization subject to divergence constraints. The trade-off is that this requires a number of heuristics, such as bounding mutual information and estimating the true divergence. Both are difficult in practice (Belghazi et al., 2018). As with most variants,  we consider the relaxed objective and fix the weightings, however by considering joint entropy instead of mutual information directly, we step slightly outside this framework. This allows us to produce a tractable objective that can be solved with more direct optimization approaches.
Symmetry has been considered in the literature before to equally emphasize both the encoding and decoding distributions. Pu et al. (2017) show that an asymmetric objective can produce overly broad marginals, and suggest using a symmetric KL divergence. (Dumoulin et al., 2017;Donahue et al., 2016) propose an encoder for GAN (Goodfellow et al., 2014) models and train it with JSD. In each of these cases, the symmetric divergence necessitates adversarial training. We show that with the right combination of objective terms, it is possible to both target a symmetric objective and still get tractable optimization.
Mutual information, together with disentanglement, is considered to be a cornerstone for useful representations (Belghazi et al., 2018;Hjelm et al., 2019). Normalizing flows (Rezende & Mohamed, 2015;Dinh et al., 2014;2016;Kingma & Dhariwal, 2018;Ho et al., 2019) directly maximizes mutual information by restricting the architecture to be invertible and tractable. This, however, requires the latent dimension to be the same as the dimension of the observations (i.e., no bottleneck). As a consequence, normalizing flows are not well suited to learning a concise representation of high dimensional data (e.g., images). Here, MIM often yields mappings that are approximately invertible, with high mutual information and low reconstruction errors.
Bornschein et al. (2015) share some of the same design principles as MIM, i.e., symmetry and encoder/decoder consistency. However, their formulation models the joint density in terms of the geometric mean between the encoder and decoder, for which one must compute an expensive partition function. (Pu et al., 2017) focuses on minimizing symmetric KL, but must use an adversarial learning procedure, while MIM can be minimized directly.

Conclusions
We introduce a new representation learning framework, named the mutual information machine (MIM), that defines a latent generative model built around three principles: consistency between the encoding and decoding distributions, high mutual information between the observed and latent variables, and low marginal entropy. This yields a learning objective that can be directly optimized by stochastic gradient descent with reparameterization, as opposed to adversarial learning used in related frameworks. We show that the MIM framework produces highly informative representations and is robust against posterior collapse. Most importantly, MIM greatly benefits from additional capacity; as the encoder and decoder become larger and more expressive, MIM retains its highly informative representation, and consistently shows improvement in its modelling of the underlying distribution as measured by negative log-likelihood. The stability, robustness, and ease of training make MIM a compelling framework for latent variable modelling across a variety of domains.

A. Code
Code and data are available from https://research.seraphlabs.ca/projects/mim/index.html In what follows we provide detailed derivations of key elements of the formulation in the paper, namely, Equations (6), and (11). We also consider the relation between MIM based on the Jensen-Shannon divergence and the symmetric KL divergence.

B.1. Regularized JSD and Entropy
First we develop the relation in Equation (6), between Jensen-Shannon divergence of the encoder and decoder, the average joint entropy of the encoder and decoder, and the joint entropy of the mixture distribution M S .
The Jensen-Shannon divergence with respect to the encoding distribution q θ (z | x) P(x) and the decoding distribution p θ (x | z) P(z) is defined as ) is a mixture of the encoding and decoding distributions. Adding on the regularizer R H

B.2. MIM Consistency
Here we discuss in greater detail how the learning algorithm encourages consistency between the encoder and decoder of a MIM model, beyond the fact that they are fit to the same sample distribution. To this end we expand on several properties of the model and the optimization procedure.

B.2.1. MIM CONSISTENCY REGULARIZER
In what follows we derive the form of the MIM consistency regularizer, R MIM (θ), given in Equation (10). Recall that we define M θ = 1 2 (p θ (x, z) + q θ (x, z)). We can show that L MIM is equivalent to L CE plus a regularizer by taking their difference.
where R MIM (θ) is non-negative, and is zero only when the encoding and decoding distributions are consistent (i.e., they represent the same joint distribution). To prove that R MIM (θ) ≥ 0 we now construct Equation (10) in terms of expectation over a joint distribution, which yields where the inequality follows Jensen's inequality, and equality holds only when q θ (x, z) = p θ (x, z) (i.e., encoding and decoding distributions are consistent).

B.2.2. SELF-CORRECTING GRADIENT
One important property of the optimization follows directly from the difference between the gradient of the upper bound L MIM and the gradient of the cross-entropy loss L CE . By moving the gradient operator into the expectation using reparametrization, one can express the gradient of L MIM (θ) in terms of the gradient of log M θ and the regularization term in Equation (10). That is, with some manipulation one obtains which shows that for any data point where a gap q θ > p θ exists, the gradient applied to p θ grows with the gap, while placing correspondingly less weight on the gradient applied to q θ . The opposite is true when q θ < p θ . In both case this behaviour encourages consistency between the encoder and decoder. Empirically, we find that the encoder and decoder become reasonably consistent early in the optimization process.

B.2.3. NUMERICAL STABILITY
Instead of optimizing an upper bound L MIM , one might consider a direct optimization of L CE . Earlier we discussed the importance of the consistency regularizer in L MIM . Here we motivate the use of L MIM from a numerical perspective point of view. In order to optimize L CE directly, one must convert log q θ and log p θ to q θ and p θ . Unfortunately, this is has the potential to produce numerical errors, especially with 32-bit floating-point precision on GPUs. While various tricks can reduce numerical instability, we find that using the upper bound eliminates the problem while providing the additional benefits outlined above.

B.2.4. TRACTABILITY
As mentioned earlier, there may be several ways to combine the encoder and decoder into a single probabilistic model. One possibility we considered, as an alternative to M θ in Equation (8), is where β = √ q θ p θ dx dz is the partition function, similar to (Bornschein et al., 2015). One could then define the objective to be the cross-entropy as above with a regularizer to encourage β to be close to 1, and hence to encourage consistency between the encoder and decoder. This, however, requires a good approximation to the partition function. Our choice of M θ avoids the need for a good value approximation by using reparameterization, which results in unbiased low-variance gradient, independent of the accuracy of the approximation of the value.

B.3. MIM Loss Decomposition
Here we show how to break down the L MIM into the set of intuitive components given in Equation (11). To this end, first note the definition of L MIM : We will focus on the first half of Equation (19) for now, It will be more clear to write out the first term of Equation (20), We then add and subtract 1 4 H P (z), where 1 4 H P (z) = − 1 4 x,z P(z) log(P(z))dxdz = − 1 4 x,z p θ (x | z) P(z) log(P(z))dxdz Writing out 1 4 CE ( p θ (x | z) P(z) , p θ (x, z) ) + 1 4 H P (z) − 1 4 H P (z) and combining terms, we obtain The second term in Equation (20) can then be rewritten as Combining Equations (21) and (22), we get the interpretable form for Equation 20, i.e., We can use the same basic steps to derive an analogous expression for CE ( M S , q θ (x, z) ) in Equation (19) and combine it with Equation (23) to get the final interpretable form:

C. MIM in terms of Symmetric KL Divergence
As discussed above, the VAE objective can be expressed as minimizing the KL divergence between the joint anchored encoding and anchored decoding distributions. Below we consider a model formulation using the symmetric KL divergence (SKL), the second term of which is the VAE objective. The mutual information regularizer R H (θ) given in Equation (5) can be added to SKL to obtain a cross-entropy objective that looks similar to MIM: When the model priors are equal to the anchors, this regularized SKL and MIM are equivalent. In general, however, the MIM loss is not a bound on the regularized SKL.
In what follows we explore the relation between SKL and JSD. In Section B.1 we showed that the Jensen-Shannon divergence can be written as Using Jensen's inequality, we can bound JSD(θ) from above, From Equation (24), if we add the regularizer R H (θ) and combine terms, we get Interestingly, we can write this in terms of KL divergence, which gives the exact relation between JSD and SKL.
D. Learning

D.1. MIM Parametric Priors
There are several effective ways to parameterize the priors. For the 1D experiments below we model p θ (z) using linear mixtures of isotropic Gaussians. With complex, high dimensional data one might also consider more powerful models (e.g., autoregressive, or flow-based priors). Unfortunately, the use of complex models typically increases the required computational resources, and the training and inference time. As an alternative we use for image data the vampprior (Tomczak & Welling, 2017), which models the latent prior as a mixture of posteriors, i.e., p θ (z) = K k=1 q θ (z|x = u k ) with learnable pseudo-inputs {u k } K k=1 . This is effective and allows one to reduce the need for additional parameters (see (Tomczak & Welling, 2017) for details on vampprior's effect over gradient estimation).
Another useful model with high dimensional data, following (Bornschein et al., 2015), is to define q θ (x) as the marginal of the decoding distribution; i.e., Like the vampprior, this entails no new parameters. It also helps to encourage consistency between the encoding and decoding distributions. In addition it enables direct empirical comparisons of VAE learning to MIM learning, because we can then use identical parameterizations and architectures for both. During learning, when q θ (x) is defined as the marginal (25), we evaluate log q θ (x) with a single sample and reparameterization. When z is drawn directly from the latent prior: When z is drawn from the encoder, given a sample observation, we use importance sampling: Complete derivations for learning with the marginal prior are provided in Sec. 4.2.

D.2. Gradient Estimation
Optimization is performed through minibatch stochastic gradient descent. To ensure unbiased gradient estimates ofL MIM we use the reparameterization trick (Kingma & Welling, 2013;Rezende et al., 2014) when taking expectation with respect to continuous encoder and decoder distributions, q θ (z|x) and p θ (x|z). Reparameterization entails sampling an auxiliary variable ∼ p( ), with known p( ), followed by a deterministic mapping from sample variates to the target random variable, that is p θ (z) = g θ ( ) and q θ (z|x) = h θ ( , x) for prior and conditional distributions. In doing so we assume p( ) is independent of the parameters θ. It then follows that where f θ (z) is the loss function with parameters θ. It is common to let p( ) be standard normal, ∼ N (0, 1), and for z|x to be Gaussian with mean µ θ (x) and standard deviation σ θ (x), in which case z = σ θ (x) + µ θ (x), A more generic exact density model can be learned by mapping a known base distribution (e.g., Gaussian) to a target distribution with normalizing flows (Dinh et al., 2014;2016;Rezende & Mohamed, 2015).
In the case of discrete distributions, e.g., with discrete data, reparameterization is not readily applicable. There exist continuous relaxations that permit reparameterization (e.g., (Maddison et al., 2016;Tucker et al., 2017)), but current methods are rather involved in practice, and require adaptation of the objective function or the optimization process. Here we simply use the REINFORCE algorithm (Sutton et al., 1999) for unbiased gradient estimates, as follows A detailed derivation follows the use of the relation below, in order to provide unbiased gradient estimates as follows which facilitate the use of samples to approximate the integral.

D.3. Training Time
Training times of MIM models are comparable to training times for VAEs with comparable architectures. One important difference concerns the time required for sampling from the decoder during training. This is particularly significant for models like auto-regressive decoders (e.g., (Kingma et al., 2016)) for which sampling is very slow. In such cases, we find that we can also learn effectively with a sampling distribution that only includes samples from the encoding distribution, i.e., P(x) q θ (z|x), rather than the mixture. We refer to this particular MIM variant as asymmetric MIM (or A-MIM). We use it in Sec. 5.2 when working with the PixelHVAE architecture (Kingma et al., 2016).

E. Posterior Collapse in VAE
Here we discuss a possible root cause for the observed phenomena of posterior collapse, and show that VAE learning can be viewed as an asymmetric MIM learning with a regularizer that encourages the appearance of the collapse. We further support that idea in the experiments in Section 5.1. As discussed earlier, VAE learning entails maximization of a variational lower bound (ELBO) on the log-marginal likelihood, or equivalently, given Equation (15), the VAE loss in terms of expectation over a joint distribution: To connect the loss in Equation (26) to MIM, we first add the expectation of log P(x), and scale the loss by a factor of 1 2 , to obtain (log(p θ (x|z)P(z)) + log(q θ (z|x)P(x))) + log P(x) + log q θ (z|x) where P(x) is the data distribution, which is assumed to be independent of model parameters θ and to exist almost everywhere (i.e., complementing P(z)). Importantly, because P(x) does not depend on θ, the gradients of Eqs. (26) and (27) are identical up to a multiple of 1 2 , so they share the same stationary points. Combining IID samples from the data distribution, x i ∼ P(x), with samples from the corresponding variational posterior, z i ∼ q θ (z|x i ), we obtain a joint sampling distribution; i.e., The sum of the last three terms in Equation (28)  Equations (15) and (28), the VAE objective and VAE as regularized cross entropy objective respectively, define equivalent optimization problems, under the assumption that P(x) and samples x ∼ P(x) do not depend on the parameters θ, and that the optimization is gradient-based. Formally, the VAE objectives (15) and (28)  Equation (28) is the average of two cross-entropy objectives ( i.e., between sample distribution M VAE S and the model decoding and encoding distributions, respectively), along with a joint entropy term (i.e., last three terms), which can be viewed as a regularizer that encourages a reduction in mutual information and increased entropy in z and x. We note that Equation (28) is similar to the MIM objective in Equation (8), but with a different sample distribution, where the priors are defined to be the anchors, and with an additional regularizer. In other words, Equation (28) suggests that VAE learning implicitly lowers mutual information. This runs contrary to the goal of learning useful latent representations, and we posit that it is an underlying root cause for posterior collapse, wherein the trained model show low mutual information which can be manifested as an encoder which matches the prior, and thus provides weak information about the latent state (e.g., see (Chen et al., 2016b) and others). We point the reader to Section F.1 for empirical evidence for the use of a joint entropy as a mutual information regularizer.

F. Additional Experiments
Here we provide additional experiments that further explore the characteristics of MIM learning. Figure 10. Effects of entropy as a mutual information regularizer in 2D x and 2D z synthetic problem. VAE and MIM models with 2D inputs, a 2D latent space, and 5, 20 and 500 hidden units. Top row: Black contours depict level sets of P(x); red dots are reconstructed test points. Bottom row: Green contours are one standard deviation ellipses of q θ (z|x) for test points. Dashed black circles depict one standard deviation of P(z). Here we added Hq θ (x, z) to VAE loss, and subtracted HM S (x, z) from MIM loss, in order to demonstrate the effect of entropy on mutual information. Posterior collapse in VAE is mitigated following the increased mutual information. MIM, on the other hand, demonstrates a severe posterior collapse as a result of the reduced mutual information (i.e., posterior matches prior over z almost perfectly). (see inset quantities).

F.1. Entropy as Mutual Information Regularizer
Here we examine the use of entropy as a mutual information regularizer. We repeat the experiment in Section 5.1 with added entropy regularizer. Figure 10 depicts the effects of an added H q θ (x, z) to the VAE loss, and a subtracted H M S (x, z) from MIM . The corresponding quantitative values are presented in Figure 11. Adding the entropy regularizer leads to increased the mutual information, and subtracting it results in a strong posterior collapse, which in turn is reflected in the reconstruction quality. While such an experiment does not represent a valid probabilistic model, it supports our use of entropy as a regularizer (cf. Eq. (5)) for JSD in order to define a consistent model with high mutual information.  Figure 11. Effects of entropy as a mutual information regularizer in 2D x and 2D z synthetic problem. Test performance for modified MIM (blue) and modified VAE (red) for the 2D GMM data with (cf. Fig. 10), all as functions of the number of hidden units (on x-axis). Each plot shows the mean and standard deviation of 10 experiments. Adding encoding entropy regularizer to VAE loss leads to high mutual information (i.e., prevent posterior collapse), low reconstruction error, and better classification accuracy. Subtracting sample entropy regularizer from MIM loss results in almost zero mutual information (severe collapse), which leads to poor reconstruction error and classification accuracy. We explore the influence of consistency regularizer R θ . CE and MIM indicate the loss, LCE or LMIM (the regularized objective), respectively. Top row shows anchor P(x) (dashed), prior q θ (x) (red), and reconstruction distribution xi ∼ P(x) → zi ∼ q θ (z|xi) → x i ∼ p θ (x|zi) (green). Bottom row mirrors the top row, with anchor P(z) (dotted), prior p θ (z) (blue), and reconstruction distribution zi ∼ P(z) → xi ∼ p θ (x|zi) → z i ∼ q θ (z|x) (yellow). In (c-d) the reconstruction is replaced with decoding from anchors zi ∼ P(z) → x i ∼ p θ (x|zi) (green), and encoding xi ∼ P(x) → z i ∼ q θ (z|x) (yellow). In (e-f) the reconstruction is replaced with decoding from priors zi ∼ p θ (z) → x i ∼ p θ (x|zi) (green), and encoding xi ∼ q θ (x) → z i ∼ q θ (z|x) (yellow). While both models offers similar reconstruction (a-b), and similar consistency w.r.t. the anchors (c-d), only MIM finds a consistent model (e-f). See text for details.
Here we explore properties of models for 1D x and z, learned with L MIM and L CE , the difference being the model consistency regularizer R MIM (θ). All model priors and conditional likelihoods (q θ (x), q θ (z|x), p θ (z), p θ (x|z)) are parameterized as 10-component Gaussian mixture models, and optimized during training. Means and variances for the conditional distributions were regressed with 2 fully connected layers (h ∈ R 10 ) and a swish activation function (Ramachandran et al., 2018).
Top and bottom rows in Fig. 12 depict distributions in observations and latent spaces respectively. Dashed black curves are anchors, P(x) on top, and P(z) below (GMMs with up to 3 components). Learned model priors, q θ (x) and p θ (z), are depicted as red (top) and blue (bottom) curves.
Green histograms in Fig. 12(a,b) depict reconstruction distributions, computed by passing fair samples from P(x) through the encoder to z and then back through the decoder to x. Similarly the yellow histograms shows samples from P(z) passed through the decoder and then back to the latent space. For both losses these reconstruction histograms match the anchor priors well. In contrast, only the priors that were learned with L CE loss approximates the anchor well, while the L MIM priors do not. To better understand that, we consider two generative procedures: sampling from the anchors, and sampling from the priors.
Anchor consistency is depicted in Fig. 12(c,d), where Green histograms are marginal distributions over x from the anchored decoder (i.e., samples from P(z)p θ (x|z) ). Yellow are marginals over z from the anchored encoders P(x)q θ (z|x). One can see that both losses results in similar quality of matching the corresponding opposite anchors.
Priors consistency is depicted in Fig. 12(e,f), where Green histograms are marginal distributions over x from the model decoder p θ (z)p θ (x|z). Yellow depicts marginals over z from the model encoder q θ (x)q θ (z|x). Importantly, with L MIM the encoder and decoder are consistent; i.e., q θ (x) (red curve) matches the decoder marginal, while p θ (z) (blue) matches the encoder marginal. The model trained with L CE (i.e., without consistency prior) fails to learn a consistent encoder-decoder pair. We note that in practice, with expressive enough priors, L MIM will be a tight bound for L CE . Figure 13. MIM prior expressiveness. In this experiment we explore the effect of learning a prior, where the priors q(x) and p(z) are normal Gaussian distributions. Top row shows anchor P(x) (dashed), prior q θ (x) (red), and decoding distribution zi ∼ p θ (z) → x i ∼ p θ (x|zi) (green). Bottom row mirrors the top row, with anchor P(z) (dotted), prior p θ (z) (blue), and encoding distribution xi ∼ q θ (x) → z i ∼ q θ (z|x) (yellow). As can be seen, parameterizing priors affects all learned distributions, supporting the notion of optimization of a single model M θ . We point that (a) demonstrates the best consistency between the priors and corresponding generated samples, following the additional expressiveness.

F.3. Parameterizing the Priors
Here we explore the effect of parameterizing the latent and observed priors. A fundamental idea in MIM is the concept of a single model, M θ . As such, parameterizing a prior increases the global expressiveness of the model M θ . Fig. 13 depicts the utilization of the added expressiveness in order to increase the consistency between the encoding and decoding model distribution, in addition to the consistency of M θ with M S .

F.4. Effect of Consistency Regularizer on Optimization
Here we explore whether a learned model with consistent encoding-decoding distributions (i.e., trained with L MIM ) also constitutes an optimal solution of a CE objective (i.e., trained with L CE ). Results are depicted in Fig. 14. In order to distinguish between the effects of the optimization from the consistency regularizer we initialize a MIM model by pre-training it with L CE loss followed by L MIM training in Fig. 14(i), and vice verse in Fig. 14(ii). (a-b,e-f) All trained models in Fig. 14 exhibit similarly good reconstruction (green matches dashed black). (c-d,g-h) However, only models that were trained with L MIM exhibit encoding-decoding consistency (green matches red, yellow matches blue). While it is clear that the optimization plays an important role (i.e., different initialization leads to different local optimum), it is also clear that encoding-decoding consistency is not necessarily an optimum of L CE , as depicted in a non-consistent model (h) which was initialized with a consistent model (g). Not surprisingly, without the consistency regularizer training with L CE results in better fit of priors to anchors (f) as it is utilizing the expressiveness of the parametric priors in matching the sample distribution.  Figure 14. Effects of MIM consistency regularizer and optimization on encoding-decoding consistency. (i) and (ii) differ in initialization order. Odd rows: anchor P(x) (dashed), prior q θ (x) (red). Even rows: anchor P(z) (dotted), prior p θ (z) (blue). (a-b,e-f) Reconstruction xi ∼ P(x) → zi ∼ q θ (z|xi) → x i ∼ p θ (x|zi) (x i green, zi yellow). (c-d,g-h) Prior decoding zi ∼ p θ (z) → x i ∼ p θ (x|zi) (green), and prior encoding xi ∼ q θ (x) → zi ∼ q θ (z|xi) (yellow). See text for details. . MIM (blue) and VAE (red) for 20D GMM data, all as function of the latent dimensionality, from 2 to 20 (on x-axis). Plots depict mean and standard deviation of 10 experiments. MIM learning produces higher mutual information and classification accuracy, with lower test reconstruction error, while VAE yields better data log likelihoods. The VAE suffers from increased collapse as latent dimensionality grows.

F.5. Bottleneck in Low Dimensional Synthetic Data
Here we consider synthetic 20D data from a 5-component GMM, with independent training and test sets, and latent representation between 2D and 20D. This ensures that the distribution is well modeled with a relatively simple architecture, like that in Sec. 5.1. This experiment extends the experiment in Fig. 2 by adding a bottleneck, similar to the experiment in Fig. 3. We used here the same experimental setup that was used in Fig. 2.
Results are shown in Fig. 15. MIM produces higher mutual information, and better classification, as the latent dimensionality grows, while VAE increasingly suffers from posterior collapse, which leads to lower mutual information, and lower classification accuracy. The test negative log likelihood scores (NLL) of MIM are not as good as VAE scores in part because the MIM encoder produces very small posterior variance, approaching a deterministic encoder. Nevertheless, MIM produces lower test reconstruction errors. These results are consistent with those in Sec. 5.1.

G. Additional Results
Here we provide additional visualization of various MIM and VAE models which were not included in the main body of the paper.

G.1. Reconstruction and Samples for MIM and A-MIM
In what follows we show samples and reconstruction for MIM (i.e., with convHVAE architecture), and A-MIM (i.e., with PixelHVAE architecture). We demonstrate, again, that a powerful enough encoder allows for generation of samples which are comparable to VAE samples.

G.2. Latent Embeddings for MIM and A-MIM
In what follows we show additional t-SNE visualization of unsupervised clustering in the latent representation for MIM (i.e., with convHVAE architecture), and A-MIM (i.e., with PixelHVAE architecture).