Semi-Supervised Learning with Normalizing Flows
Pavel Izmailov, Polina Kirichenko, Marc Finzi, Andrew Gordon Wilson
Introduction
The discriminative approach to classification models the probability of a class label given an input directly. The generative approach, by contrast, models the class conditional density for the data , and then uses Bayes rule to find . In principle, generative modelling has long been more alluring, for the effort is focused on creating an interpretable object of interest, and “what I cannot create, I do not understand”. In practice, discriminative approaches typically outperform generative methods, and thus are far more widely used.
The challenge in generative modelling is that standard approaches to density estimation are often poor descriptions of high-dimensional natural signals. For example, a Gaussian mixture directly over images, while highly flexible for estimating densities, would specify similarities between images as related to Euclidean distances of pixel intensities, which would be a poor inductive bias for handling translations or representing other salient statistical properties. Recently, generative adversarial networks (Goodfellow et al., 2014), variational autoencoders (Kingma & Welling, 2013), and normalizing flows (Dinh et al., 2014), have led to great advances in unsupervised generative modelling, by leveraging the inductive biases of deep convolutional neural networks.
Normalizing flows are a pleasingly simple approach to generative modelling, which work by transforming a distribution through an invertible neural network. Since the transformation is invertible, it is possible to exactly express the likelihood over the observed data, to train the neural network mapping. The network provides both useful inductive biases, and a flexible approach to density estimation. Normalizing flows also admit controllable latent representations and can be sampled efficiently, unlike auto-regressive models (Papamakarios et al., 2017; Oord et al., 2016). Moreover, recent work (Dinh et al., 2016; Kingma & Dhariwal, 2018; Behrmann et al., 2018; Chen et al., 2019; Song et al., 2019) demonstrated that normalizing flows can produce high-fidelity samples for natural image datasets.
Advances in unsupervised generative modelling, such as normalizing flows, are particularly compelling for semi-supervised learning, where we wish to share structure over labelled and unlabelled data, to make better predictions of class labels on unseen data. In this paper, we introduce an approach to semi-supervised learning with normalizing flows, by modelling the density in the latent space as a Gaussian mixture, with each mixture component corresponding to a class represented in the labelled data. This Flow Gaussian Mixture Model (FlowGMM) is to the best of our knowledge the first approach to semi-supervised learning with normalizing flows that provides an exact joint likelihood over both labelled and unlabelled data, for end-to-end training.A short version of this work first appeared at the ICML 2019 Normalizing Flows Workshop (Izmailov et al., 2019). At the same workshop, Atanov et al. (2019) proposed a different approach that uses a class-conditional normalizing flow as the latent distribution.
We illustrate FlowGMM with a simple example in Figure 1. We are solving a binary semi-supervised classification problem on the dataset shown in panel (a): the labeled data are shown with triangles colored according to their class, and unlabeled data are shown with blue circles. We introduce a Gaussian mixture with two components corresponding to each of the classes, shown in panel (c) in the latent space and an invertible transformation . The transformation is then trained to map the data distribution in the data space to the latent Gaussian mixture in the space, mapping the labeled data to the corresponding mixture component. We visualize the learned transformation in panel (b), showing the positions of the images for all of the training data points. The inverse of this mapping serves as a class-conditional generative model, that we visualize in panel (d). To classify a data point in the input space we compute its image in the latent space, and pick the class corresponding to the Gaussian that is closest to . We visualize the decision boundary of the learned classifier with a dashed line in panel (a).
FlowGMM naturally encodes the clustering principle: the decision boundary between classes must lie in the low-density region in the data space. Indeed, in the latent space the decision boundary between two classes coincides with the hyperplane perpendicular to the line segment connecting means of the corresponding mixture components and passing through the midpoint of this line segment (assuming the components are normal distributions with identity covariance matrices); in panel (b) of Figure 1 we show the decision boundary in the latent space with a dashed line. The density of the latent distribution near the decision boundary is low. As the flow is trained to represent data as a transformation of this latent distribution, the density near the decision boundary should also be low. In panel (a) of Figure 1 the decision boundary indeed lies in the low-density region.
We propose FlowGMM, a new probabilistic classification model based on normalizing flows that can be naturally applied to semi-supervised learning.
We show that FlowGMM has good performance on a broad range of semi-supervised tasks, including image, text and tabular data classification.
We propose a new type of probabilistic consistency regularization that significantly improves FlowGMM on image classification problems.
To demonstrate the interpretability of FlowGMM, we visualize the learned latent space representations for the proposed semi-supervised model and show that interpolations between data points from different classes pass through low-density regions. We also show how FlowGMM can be used for feature visualization in real-time, without requiring gradients.
We show that the predictive uncertainties of FlowGMM can be naturally calibrated by scaling the variances of mixture components.
We provide code for FlowGMM at: https://github.com/izmailovpavel/flowgmm
Related Work
Kingma et al. (2014) represents one of the earliest works on semi-supervised deep generative modelling, demonstrating how the likelihood model of a variational autoencoder (Kingma & Welling, 2013) could be used for semi-supervised image classification. Xu et al. (2017) later extended this framework to semi-supervised text classification.
Many generative models for classification (Salimans et al., 2016; Nalisnick et al., 2019; Chen et al., 2019) have relied upon multitask learning, where a shared latent representation is learned for the generative model and the classifier. With the method of Chen et al. (2019), hybrid modeling is observed to reduce performance for both tasks in the supervised case. While GANs have achieved promising performance on semi-supervised tasks, Dai et al. (2017) showed that classification performance and generative performance are in direct conflict: a perfect generator provides no benefit to classification performance.
Some works on normalizing flows, such as RealNVP (Dinh et al., 2016), have used class-conditional sampling, where the transformation is conditioned on the class label. These approaches pass the class label as an input to coupling layers, conditioning the output of the flow on the class.
Deep Invertible Generalized Linear Model (DIGLM, Nalisnick et al., 2019), most closely related to our work, trains a classifier on the latent representation of a normalizing flow to perform supervised or semi-supervised image classification. Our approach is principally different, as we use a mixture of Gaussians in the latent space and perform classification based on class-conditional likelihoods (see (5)), rather than training a separate classifier. One of the key advantages of our approach is the explicit encoding of clustering principle in the method and a more natural probabilistic interpretation.
Indeed, many approaches to semi-supervised learn from the labelled and unlabelled data using different (and possibly misaligned) objectives, often also involving two step procedures where the unsupervised model is used as pre-processing for a supervised approach. In general, FlowGMM is distinct in that the generative model is used directly as a Bayes classifier, and in the limit of a perfect generative model the Bayes classifier achieves a provably optimal misclassification rate (see e.g. Mohri et al., 2018). Moreover, approaches to semi-supervised classification, such as consistency regularization (Laine & Aila, 2016; Miyato et al., 2018; Tarvainen & Valpola, 2017; Athiwaratkun et al., 2019; Verma et al., 2019; Berthelot et al., 2019), typically focus on image modelling. We instead focus on showcasing the broad applicability of FlowGMM on text, tabular, and image data, as well as the ability to conveniently discover interpretable structure.
Background: Normalizing Flows
The normalizing flow (Dinh et al., 2016) is an unsupervised model for density estimation defined as an invertible mapping from the data space to the latent space . We can model the data distribution as a transformation applied to a random variable from the latent distribution , which is often chosen to be Gaussian. The density of the transformed random variable is given by the change of variables formula
The mapping is implemented as a sequence of invertible functions, parametrized by a neural network with architecture that is designed to ensure invertibility and efficient computation of log-determinants, and a set of parameters that can be optimized. The model can be trained by maximizing the likelihood in Equation (1) of the training data with respect to the parameters .
Flow Gaussian Mixture Model
We introduce the Flow Gaussian Mixture Model (FlowGMM), a probabilistic generative model for semi-supervised learning with normalizing flows. In FlowGMM, we introduce a discrete latent variable for the class label, . Our latent space distribution, conditioned on a label , is Gaussian with mean and covariance :
The marginal distribution of is then a Gaussian mixture. When the classes are balanced, this distribution is
Combining equations (2) and (1), the likelihood for labeled data is
over the parameters of the bijective function , which learns a density model for a Bayes classifier. In particular, given a test point , the model predictive distribution is given by
We can then make predictions for a test point with the Bayes decision rule
As an alternative to direct likelihood maximization, we can adapt the Expectation Maximization algorithm for model training as discussed in Appendix A.
Most of the existing state-of-the-art approaches to semi-supervised learning on image data are based on consistency regularization (Laine & Aila, 2016; Miyato et al., 2018; Tarvainen & Valpola, 2017; Athiwaratkun et al., 2019; Verma et al., 2019; Xie et al., 2020; Berthelot et al., 2020). These methods penalize changes in network predictions with respect to input perturbations, such as random translations and horizontal flips, with an additional loss term that can be computed on unlabeled data,
where are random perturbations of , and is the vector of probabilities over the classes.
Motivated by these methods, we introduce a new consistency regularization term for FlowGMM. Let be the label predicted on image by FlowGMM according to (5). We then define our consistency loss as the negative log likelihood of the input given the label :
This loss term encourages the model to map small perturbations of the same unlabeled inputs to the same components of the Gaussian mixture distribution in the latent space. Unlike the standard consistency loss of (6), the proposed loss in (7) takes values on the same scale as the data log likelihood (4), and indeed we find it to work better in practice. We refer to FlowGMM with the consistency term as FlowGMM-cons. The final loss for FlowGMM-cons is then the weighted sum of the consistency loss (7) and the negative log likelihood of both labeled and unlabeled data (4).
Experiments
We evaluate FlowGMM on a wide range of datasets across different application domains including low-dimensional synthetic data (Section 5.1), text and tabular data (Section 5.2), and image data (Section 5.3). We show that FlowGMM outperforms the baselines on tabular and text data. FlowGMM is also state-of-the-art as an end-to-end generative approach to semi-supervised image classification, conditioned on architecture. However, FlowGMM is constrained by the RealNVP architecture, and thus does not outperform the most powerful approaches in this setting, which involve discriminative classifiers.
In all experiments, we use the RealNVP normalizing flow architecture. Throughout training, Gaussian mixture parameters are fixed: the means are initialized randomly from the standard normal distribution and the covariances are set to . See Appendix B for further discussion on GMM initialization and training.
We first apply FlowGMM to a range of two-dimensional synthetic datasets, in order to gain a better visual intuition for the method. We use the RealNVP architecture with 5 coupling layers, defined by fully-connected shift and scale networks, each with 1 hidden layer of size 512. In addition to the semi-supervised setting, we also trained the method only using the labeled data. In Figure 2 we visualize the decision boundaries of the classifier corresponding to FlowGMM for both of these settings on the two circles and pinwheel datasets. On both datasets, FlowGMM is able to benefit from the unlabeled data to push the decision boundary to a low-density region, as expected. On the two circles problem the method is unable to fit the data perfectly as flows are homeomorphisms, and the disk is topologically distinct from an annulus. However, FlowGMM still produces a reasonable decision boundary and improves over the case when only labeled data are available. We provide additional visualizations in Appendix C, Figure 4.
2 Text and Tabular Data
FlowGMM can be especially useful for semi-supervised learning on tabular data. Consistency-based semi-supervised methods have mostly been developed for image classification, where the predictions of the method are regularized to be invariant to random flips and translations of the image. On tabular data, desirable invariances are less obvious, finding suitable transformations to apply for consistency-based methods is not-trivial. Similarly, approaches based on GANs have mostly been developed for images. We evaluate FlowGMM on the Hepmass and Miniboone UCI classification datasets (previously used in Papamakarios et al. (2017) for density estimation).
Along with standard tabular UCI datasets, we also consider text classification on AG-News and Yahoo Answers datasets. Using the recent advances in transfer learning for NLP, we construct embeddings for input texts using the BERT transformer model (Devlin et al., 2018) trained on a corpus of Wikipedia articles, and then train FlowGMM and other baselines on the embeddings.
We compare FlowGMM to the graph based label spreading method from Zhou et al. (2004), a -Model (Laine & Aila, 2016) that uses dropout perturbations, as well as supervised logistic regression, k-nearest neighbors, and a neural network trained on the labeled data only. We report the results in Table 1, where FlowGMM outperforms the alternative semi-supervised learning methods on each of the considered datasets. Implementation details for FlowGMM, the baselines, and data preprocessing details are in Appendix D.
3 Image Classification
We next evaluate the proposed method on semi-supervised image classification benchmarks on CIFAR-10, MNIST and SVHN datasets. For all the datasets, we use the RealNVP (Dinh et al., 2016) architecture. Exact implementation details are listed in the Appendix E. The supervised model is trained using the same loss (4), where all the data points are labeled ().
We present the results for FlowGMM and FlowGMM-cons in Table 2. We also report results from DIGLM (Nalisnick et al., 2019), supervised only performance on MNIST and SVHN, and the M1+M2 VAE model (Kingma et al., 2014). FlowGMM outperforms the M1+M2 model and performs better or on par with DIGLM. Furthermore, FlowGMM-cons improves over FlowGMM on all three datasets, suggesting that our proposed consistency regularization is helpful for performance.
Following Oliver et al. (2018), we evaluate FlowGMM-cons varying the number of labeled data points. Specifically, we follow the setup of Kingma et al. (2014) and train FlowGMM-cons on MNIST with , , and labeled data points. We present the results in Table 3. FlowGMM-cons outperforms the M1+M2 model of Kingma et al. (2014) in all the considered settings.
We note that the results presented in this Section are not directly comparable with the state-of-the-art methods using GANs or consistency regularization (see e.g. Laine & Aila, 2016; Dai et al., 2017; Athiwaratkun et al., 2019; Berthelot et al., 2019), as the architecture we employ is much less powerful for classification than the ConvNet and ResNet architectures that have been designed for classification without the constraint of invertibility. We believe that invertible architectures with better inductive biases for classification may help bridge this gap; invertible residual networks (Behrmann et al., 2018; Chen et al., 2019) and invertible CNNs (Finzi et al., 2019) are some of the early examples of this class of architectures.
In general, it is difficult to directly compare FlowGMM with most existing approaches, because the types of architectures available for fully generative normalizing flows are very different than what is available to (partially) discriminative approaches or even other generative methods like VAEs. This difference is due to the invertibility requirement for normalizing flows.
Model Analysis
We empirically analyze different aspcects of FlowGMM and highlight some useful features of this model. In Section 6.1 we discuss the calibration of predictive uncertainties produced by the model. In Section 6.2, we study the latent representations learned by FlowGMM. Finally, in Section 6.3, we discuss a feature visualization technique that can be used to interpret the features learned by FlowGMM.
In many applications, particularly where decision making is involved, it is crucial to have reliable confidences associated with predictions. In classification problems, well-calibrated models are expected to output accurate probabilities of belonging to a particular class. Reliable uncertainty estimation is especially relevant in semi-supervised learning since label information is limited during training. Guo et al. (2017), showed that modern deep learning models are highly overconfident, but could be easily recalibrated with temperature scaling. In this Section, we analyze the predictive uncertainties produced by FlowGMM. In Appendix Section F, we also consider out-of-domain data detection.
When using FlowGMM for classification, the class predictive probabilities are
We address this problem by learning a single scalar parameter for all components in the Gaussian mixture (the component will be ) by minimizing the negative log likelihood on a validation set. This way we can naturally re-calibrate the variance of the latent GMM. This procedure is also equivalent to applying temperature scaling (Guo et al., 2017) to logits . We test FlowGMM calibration on MNIST and CIFAR datasets in the supervised setting. On MNIST we restricted the training set size to objects, since on the full dataset the model makes too few mistakes which makes evaluating calibration harder. In Table 4, we report negative log likelihood and expected calibration error (ECE, see Guo et al. (2017) for a description of this metric). We can see that re-calibrating variances of the Gaussians in the mixture significantly improves both metrics and mitigates overconfidence. The effectiveness of this simple rescaling procedure suggests that the latent space distances learned by the flow model are correlated with the probabilities of belonging to a particular class: the closer a datapoint is to the mean of a Gaussian in the latent space, the more likely it belongs to the corresponding class.
2 Learned Latent Representations
In Appendix section H, we present images corresponding to the means of the Gaussian mixture and class-conditional samples from FlowGMM.
To explicitly test this conclusion, we compute the distribution of distances from unlabeled data to the decision boundary for FlowGMM-cons and FlowGMM Sup trained on labeled data only. In order to compute this distance exactly for an image , we find the two closest means , to the corresponding latent variable , and evaluate the expression d(x)=\frac{\big{|}\|\mu^{\prime}-f(x)\|^{2}-\|\mu^{\prime\prime}-f(x)\|^{2}\big{|}}{2\|\mu^{\prime}-\mu^{\prime\prime}\|}. We visualize the distributions of the distances for the supervised and semi-supervised method in Figure 3(c). While most of the unlabeled data are far from the decision boundary for both methods, the supervised method puts a substantially larger fraction of data close to the decision boundary. For example, the distance to the decision boundary is smaller than for unlabeled data points with supervised model, but only data points with FlowGMM-cons. This increased separation suggests that FlowGMM-cons indeed pushes the decision boundary away from the data distribution as would be desired from the clustering principle.
3 Feature Visualization
Feature visualization has become an important tool for increasing the interpretability of neural networks in supervised learning. The majority of methods rely on maximizing the activations of a given neuron, channel, or layer over a parametrization of an input image with different kinds of image regularization (Szegedy et al., 2013; Olah et al., 2017; Mahendran & Vedaldi, 2015). These methods, while effective, require iterative optimization too costly for real time interactive exploration. In this Section we discuss a simple and efficient feature visualization technique that leverages the invertibility of FlowGMM. This technique can be used with any invertible model but is especially relevant for FlowGMM, where we can use feature visualization to gain insights into the classification decisions made by the model.
where is a one hot vector at channel ; and is the standard deviation of the activations in channel over the the training set and spatial locations. This procedure can be performed at real-time rates to explore the activation parametrized by and the location without any optimization or hyper-parameters. We show the feature visualization for intermediate layers on CIFAR-10 test images in Figure 3(d). The channel being visualized appears to activate on the zeroed pixels from random translations as well as the green channel. Analyzing the features learned by FlowGMM we can gain insight into the workings of the model.
Discussion
We proposed a simple and interpretable approach for end-to-end generative semi-supervised prediction with normalizing flows. While FlowGMM does not yet outperform the most powerful discriminative approaches for semi-supervised image classification (Athiwaratkun et al., 2019; Verma et al., 2019), we believe it is a promising step towards making fully generative approaches more practical for semi-supervised tasks. As we develop improved invertible architectures, the performance of FlowGMM will also continue to improve.
Moreover, FlowGMM does outperform graph-based and consistency-based baselines on tabular data including semi-supervised text classification with BERT embeddings. We believe that the results show promise for generative semi-supervised learning based on normalizing flows, especially for tabular tasks where consistency-based methods struggle.
We view interpretability and broad applicability as a strong advantage of FlowGMM. The access to latent space representations and the feature visualization technique discussed in Section 6 as well as the ability to sample from the model can be used to obtain insights into the performance of the model in practical applications.
References
Appendix A Expectation Maximization
EM is applicable to fitting the transformed mixture of Gaussians. We can perform the exact E-step for unlabeled data in the model since
which coincides with the E-step of EM algorithm on Gaussian mixture model. On M-step, the objective has the following form:
Since the exact solution is not tractable due to complexity of the flow model, we perform a stochastic gradient step to optimize the expected log likelihood with respect to flow parameters .
Note that unlike regular EM algorithm for mixture models, we have Gaussian mixture parameters fixed in our experiments, and on M-step the update of induces the change of latent space representations.
Using EM algorithm for optimization in the semi-supervised setting on MNIST dataset with 1000 labeled images, we obtain 98.97% accuracy which is comparable to the result for FlowGMM with regular SGD training. However, in our experiments, we observed that on E-step, hard label assignment happens for unlabeled points ( for one of the classes) because of the high dimensionality of the problem (see section 6.1) which affects the M-step objective and hinders training.
Appendix B Latent Distribution Mean and Covariance Choices
In our experiments, we draw the mean vectors of Gaussian mixture model randomly from the standard normal distribution , and set the covariance matrices to identity for all classes; we fixed GMM parameters throughout training. However, one could potentially benefit from data-dependent placing of means in the latent space. We experimented with different initialization methods, in particular, initializing means using the mean point of latent representations of labeled data in each class: where represents labeled data points from class and is the total number of labeled points in that class. In addition, we can scale all means by a scalar value to increase or decrease distances between them. We observed that such initialization leads to much faster convergence of FlowGMM on semi-supervised classification on MNIST dataset, however, the final performance of the model was worse compared to the one with random mean placing. We hypothesize that it becomes easier for the flow model to warm up faster with data-dependent initialization because Gaussian means are closer to the initial latent representations, but afterwards the model gets stuck in a suboptimal solution.
GMM training
FlowGMM would become even more flexible and expressive if we could learn Gaussian mixture parameters in a principled way. In the current setup where means are sampled from the standard normal distribution, the distances between mixture components are about where is the dimensionality of the data (see Appendix G). Thus, classes are quite far apart from each other in the latent space, which, as observed in Section 6.1, leads to model miscalibration. Training GMM parameters can further increase interpretability of the learned latent space representations: we can imagine a scenario in which some of the classes are very similar or even intersecting, and it would be useful to represent it in the latent space. We could train GMM by directly optimizing likelihood (4), or using expectation maximization (see Section A), either jointly with the flow parameters or iteratively switching between training flow parameters with the fixed GMM and training GMM with the fixed flow. In our initial experiments on semi-supervised classification on MNIST, training GMM jointly with the flow parameters did not improve performance or lead to substantial change of the latent representations. Further improvements require careful hyper-parameter choice which we leave for future work.
Appendix C Synthetic Experiments
In Figure 4 we visualize the classification decision boundaries of FlowGMM as well as the learned mapping to the latent space and generated samples for three different synthetic datasets.
Appendix D Tabular data preparation and hyperparameters
The AG-News and Yahoo Answers were constructed by applying BERT embeddings to the text input, yielding a dimensional vector for each data point. AG-News has classes while Yahoo Answers has . The UCI datasets Hepmass and Miniboone were constructed using the data preprocessing from Papamakarios et al. (2017), but with the inclusion of the removed background process class so that the two problems can be used for binary classification. We then subsample the fraction of background class examples so that the dataset is balanced. For each of the datasets, a separate validation set of size k was used to tune hyperparameters. All neural network models use the ADAM optimizer (Kingma & Ba, 2014).
k-Nearest Neighbors: We tested both using both L2 distance and L2 with inputs normalized to unit norm, ( distance), and the latter performed the best. The value chosen in the method was found sweeping over , and the optimal values for each of the datasets are shown in 5.
3 Layer NN + Dropout: The -Layer NN + Dropout baseline network has three fully connected hidden layers with inner dimension , ReLU nonlinearities, and dropout with . We use the learning rate e for training the supervised baseline across all datasets.
Label Spreading: We use the local and global consistency method from Zhou et al. (2004), where in our case is the matrix of labels for the labeled, unlabeled, and test data but filled with zeros for unlabeled and test. computed from the affinity matrix where . This is equivalent to L2 distance on the inputs normalized to unit magnitude. Because the algorithm scales poorly with number of unlabeled points for dense affinity matrices, , we we subsampled the number of unlabeled data points to and test data points to for this graph method. However, we also evaluate the label spreading algorithm with a sparse kNN affinity matrix on using a larger subset of unlabeled data. The two hyperparameters for label spreading (/ and ) were tuned by separate grid search for each of the datasets. In both cases, we use the inductive variant of the algorithm where the test data is not included in the unlabeled data.
FlowGMM: We train our FlowGMM model with a RealNVP normalizing flow, similar to the architectures used in Papamakarios et al. (2017). Specifically, the model uses coupling layers, with hidden layer each and hidden units for the UCI datasets but for text classification. UCI models were trained for epochs of unlabeled data and the text datasets were trained for epochs of unlabeled data. The labeled and unlabeled batch sizes are the same as in the -Model.
The tuned learning rates for each of the models that we used for these experiments are shown in Table 5.
Appendix E Image data preparation and hyperparameters
We use the CIFAR-10 multi-scale architecture with scales, each containing coupling layers defined by residual blocks with feature maps. We use Adam optimizer (Kingma & Ba, 2014) with learning rate for CIFAR-10 and SVHN and for MNIST. We train the supervised model for epochs, and semi-supervised models for passes through the labeled data for CIFAR-10 and SVHN and passes for MNIST. We use a batch size of and sample labeled and unlabeled data points in each mini-batch. For the consistency loss term (7), we linearly increase the weight from to for the first epochs following Athiwaratkun et al. (2019). For FlowGMM and FlowGMM-cons, we re-weight the loss on labeled data by (value tuned on validation (Kingma et al., 2014) on CIFAR-10), as otherwise, we observed that the method underfits the labeled data.
Appendix F Out-of-domain data detection
Density models have held promise for being able to detect out-of-domain data, an especially important task for robust machine learning systems (Nalisnick et al., 2019). Recently, it has been shown that existing flow and autoregressive density models are not as apt at this task as previously thought, yielding high likelihood on images coming from other (simpler) distributions. The conclusion put forward is that datasets like SVHN are encompassed by, or have roughly the same mean but lower variance than, more complex datasets like CIFAR-10 (Nalisnick et al., 2018). We examine this hypothesis in the context of our flow model which has a multi-modal latent space distribution unlike methods considered in Nalisnick et al. (2018).
Using a fully supervised model trained on MNIST, we evaluate the log likelihood for data points coming from the NotMNIST dataset, consisting of letters instead of digits, and the FashionMNIST dataset. We then train a supervised model on the more complex dataset FashionMNIST and evaluate on MNIST and NotMNIST. The distribution of the log likelihood on these datasets is shown in Figure 5. For the model trained on MNIST we see that the data from Fashion MNIST and NotMNIST is assigned lower likelihood, as expected. However, the model trained on FashionMNIST predicts higher likelihoods for MNIST images. The majority () of the MNIST data points get mapped into the mode of the FashionMNIST model corresponding to sandals, which is the class with the largest fraction of pixels that are zero. Similarly, for the model trained on MNIST the image of all zeros has very high likelihood and gets mapped to the mode corresponding to the digit which has the largest fraction of empty space.
Appendix G Expected Distances between Gaussian Samples
Consider two Gaussians with means sampled independently from the standard normal in -dimensional space. If is a sample from the first Gaussian, then its expected squared distances to both mixture means are:
For high-dimensional Gaussians the random variables and will be concentrated around their expectations. Since the function decreases rapidly to zero for positive , the probability of belonging to the first Gaussian saturates at 1 with the growth of dimensionality .
Appendix H FlowGMM as generative model
In Figure 6(a) we show the images corresponding to the means of the Gaussians representing each class. We see that the flow correctly learns to map the means to samples from the corresponding classes. Next, in Figure 6(b) we show class-conditional samples from the model. To produce a sample from class , we first generate , where is a temperature parameter that controls trade-off between sample quality and diversity; we then compute the samples as . We set to produce samples in Figure 6(b). As we can see, FlowGMM can produce reasonable class-conditional samples simultaneously with achieving a high classification accuracy () on the MNIST dataset.