Multi-Level Variational Autoencoder: Learning Disentangled Representations from Grouped Observations

Diane Bouchacourt, Ryota Tomioka, Sebastian Nowozin

Introduction

Representation learning refers to the task of learning a representation of the data that can be easily exploited, see Bengio et al. (2013). In this work, our goal is to build a model that disentangles the data into separate salient factors of variation and easily applies to a variety of tasks and different types of observations. Towards this goal there are multiple difficulties. First, the representative power of the learned representation depends on the information one wishes to extract from the data. Second, the multiple factors of variation impact the observations in a complex and correlated manner. Finally, we have access to very little, if any, supervision over these different factors. If there is no specific meaning to embed in the desired representation, the infomax principle, described in Linsker (1988), states that an optimal representation is one of bounded entropy which retains as much information about the data as possible. However, we are interested in learning a semantically meaningful disentanglement of interesting latent factors. How can we anchor semantics in high-dimensional representations?

We propose group-level supervision: observations are organised in groups, where within a group the observations share a common but unknown value for one of the factors of variation. For example, take images of circle and stars, of possible colors green, yellow and blue. A possible grouping organises the images by shape (circled or starred). Group observations allow us to anchor the semantics of the data (shape and color) into the learned representation. Group observations are a form of weak supervision that is inexpensive to collect. In the above shape example, we do not need to know the factor of variation that defines the grouping.

Deep probabilistic generative models learn expressive representations of a given set of observations. Among them, Kingma and Welling (2014); Rezende et al. (2014) proposed the very successful Variational Autoencoder (VAE). In the VAE model, a network (the encoder) encodes an observation into its latent representation (or latent code) and a generative network (the decoder) decodes an observation from a latent code. The VAE model performs amortised inference, that is, the observations parametrise the posterior distribution of the latent code, and all observations share a single set of parameters to learn. This allows efficient test-time inference. However, the VAE model assumes that the observations are independent and identically distributed (i.i.d.). In the case of grouped observations, this assumption is no longer true. Considering the toy example of objects grouped by shape, the VAE model considers and processes each observation independently. This is shown in Figure 1(a). The VAE model takes no advantage of the knowledge of the grouping.

How can we build a probabilistic model that easily incorporates this grouping information and learns the corresponding relevant representation? We could enforce equal representations within groups in a graphical model, using stochastic variational inference (SVI) for approximate posterior inference, Hoffman et al. (2013). However, such model paired with SVI cannot take advantage of efficient amortised inference. As a result, SVI requires more passes over the training data and expensive test-time inference. Our proposed model retains the advantages of amortised inference while using the grouping information in a simple yet flexible manner.

We present the Multi-Level Variational Autoencoder (ML-VAE), a new deep probabilistic model that learns a disentangled representation of a set of grouped observations. The ML-VAE separates the latent representation into semantically meaningful parts by working both at the group level and the observation level. Without loss of generality we assume that there are two latent factors, style and content. The content is common for a group, while the style can differ within the group. We emphasise that our approach is general in that there can be more than two factors. Moreover, for the same set of observations, multiple groupings are possible along different factors of variation. To use group observations the ML-VAE uses a grouping operation that separates the latent representation into two parts, style and content, and samples in the same group have the same content. This in turns makes the encoder learn a semantically meaningful disentanglement. This process is shown in Figure 1(b). For illustrative purposes, the upper part of the latent code represents the style (color) and the lower part the content (shape: circle or star). In Figure 1(b), after being encoded the two circles share the same shape in the lower part of the latent code (corresponding to content). The variations within the group (style), in this case color, gets naturally encoded in the upper part. Moreover, while the ML-VAE handles the case of a single sample in a group, if there are multiples samples in a group the grouping operation increases the certainty on the content. This is shown in Figure 1(b) where black circles show that the model has accumulated evidence of the content (circle) from the two disentangled codes (grey circles). The grouping operation does not need to know that the data are grouped by shape nor what shape and color represent; the only supervision is the organisation of the data in groups. At test-time, the ML-VAE generalises to unseen realisations of the factors of variation, for example the purple triangle in Figure 1(c). Using the disentangled representation, we can control the latent code and can perform operations such as swapping part of the latent representation to generate new observations, as shown in Figure 1(c). To sum-up, our contributions are as follows.

We propose the ML-VAE model to learn disentangled representations from group level supervision;

we extend amortized inference to the case of non-iid observations;

we demonstrate experimentally that the ML-VAE model learns a semantically meaningful disentanglement of grouped data;

we demonstrate manipulation of the latent representation and generalises to unseen groups.

Related Work

Research has actively focused on the development of deep probabilistic models that learn to represent the distribution of the data. Such models parametrise the learned representation by a neural network. We distinguish between two types of deep probabilistic models. Implicit probabilistic models stochastically map an input random noise to a sample of the modelled distribution. Examples of implicit models include Generative Adversarial Networks (GANs) developed by Goodfellow et al. (2014) and kernel based models, see Li et al. (2015); Dziugaite et al. (2015); Bouchacourt et al. (2016). The second type of model employs an explicit model distribution and builds on variational inference to learn its parameters. This is the case of the Variational Autoencoder (VAE) proposed by Kingma and Welling (2014); Rezende et al. (2014). Both types of model have been extended to the representation learning framework, where the goal is to learn a representation that can be effectively employed. In the unsupervised setting, the InfoGAN model of Chen et al. (2016) adapts GANs to the learning of an interpretable representation with the use of mutual information theory, and Wang and Gupta (2016) use two sequentially connected GANs. The β\beta-VAE model of Higgins et al. (2017) encourages the VAE model to optimally use its capacity by increasing the Kullback-Leibler term in the VAE objective. This favors the learning of a meaningful representation. Abbasnejad et al. (2016) uses an infinite mixture as variational approximation to improve performance on semi-supervised tasks. Contrary to our setting, these unsupervised models do not anchor a specific meaning into the disentanglement. In the semi-supervised setting, i.e. when an output label is partly available, Siddharth et al. (2017) learn a disentangled representation by introducing an auxiliary variable. While related to our work, this model defines a semi-supervised factor of variation. In the example of multi-class classification, it would not generalise to unseen classes. We define our model in the grouping supervision setting, therefore we can handle unseen classes at testing. The VAE model has been extended to the learning of representations that are invariant to a certain source of variation. In this context Alemi et al. (2017) build a meaningful representation by using the Information Bottleneck (IB) principle, presented by Tishby et al. (1999). The Variational Fair Autoencoder presented by Louizos et al. (2016) encourages independence between the latent representation and a sensitive factor with the use of a Maximum Mean Discrepancy (MMD) based regulariser, while Edwards and Storkey (2015) uses adversarial training. Finally, Chen et al. (2017) control which part of the data gets encoded by the encoder and employ an autoregressive architecture to model the part that is not encoded. While related to our work, these models require supervision on the source of variation to be invariant to. In the specific case of learning interpretable representation of images, Kulkarni et al. (2015) train an autoencoder with minibatch where only one latent factor changes. Finally, Mathieu et al. (2016) learn a representation invariant to a certain source of data by combining autoencoders trained in an adversarial manner. Multiple works perform image-to-image translation between two unpaired images collections using GAN-based architectures, see Zhu et al. (2017); Kim et al. (2017); Yi et al. (2017); Fu et al. (2017); Taigman et al. (2017); Shrivastava et al. (2017); Bousmalis et al. (2016), while Liu et al. (2017) employ a combination of VAE and GANs. Interestingly, all these models require a form of weak supervision that is similar to our setting. We can think of the two unpaired images collections as two groups of observed data, sharing image type (painting versus photograph for example). Our work differs from theirs as we generalise to any type of data and number of groups. It is unclear how to extend the cited models to the setting of more than two groups and other types of data. Also, we do not employ multiple GANs models but a single VAE-type model. While not directly related to our work, Murali et al. (2017) perform computer program synthesis using grouped user-supplied example programs, and Allamanis et al. (2017) learn continuous semantic representations of mathematical and logical expressions. Finally we mention the concurrent recent work of Donahue et al. (2017) which disentangles the latent space of GANs.

Model

2 The ML-VAE for Grouped Observations

We do not assume i.i.d. observations, but independence at the grouped observations level. The average marginal log-likelihood decomposes over groups of observations

The ELBO(G;θ,ϕs,ϕc)\textrm{ELBO}(G;\theta,\phi_{s},\phi_{c}) for a group is

In comparison, the original VAE model maximises the average ELBO over individual samples. In practise, we build an estimate of L(G,θ,ϕc,ϕs)\mathcal{L}(\mathcal{G},\theta,\phi_{c},\phi_{s}) using minibatches of group.

If we take each group G∈GbG\in\mathcal{G}_{b}, in its entirety this is an unbiased estimate. When the groups sizes are too large, for efficiency, we subsample GG and this estimate is biased. We discuss the bias in the supplementary material. The resulting algorithm is shown in Algorithm 1.

For each group GG, in step 1 of Algorithm 1 we build the group content distribution by accumulating information from the result of encoding each sample in GG. The question is how can we accumulate the information in a relevant manner to compute the group content distribution?

3 Accumulating Group Evidence using a Product of Normal densities

Experiments

We evaluate the ML-VAE on images, other forms of data are possible and we leave these for future work. In all experiments we use the Product of Normal method presented in Section 3.3 to construct the content latent representation. Our goal with the experiments is twofold. First, we want to evaluate the performance of ML-VAE to learn a semantically meaningful disentangled representation. Second, we want to explore the impact of “accumulating evidence” described in Section 3.3. Indeed when we encode test images two strategies are possible: strategy 11 is disregarding the grouping information of the test samples, i.e. each test image is a group; and strategy 22 is considering the grouping information of the test samples, i.e. taking multiple test images per identity to construct the content latent representation.

We evaluate the ML-VAE on MNIST Lecun et al. (1998). We consider the data grouped by digit label, i.e. the content latent code CC should encode the digit label. We randomly separate the 60,00060,000 training examples into 50,00050,000 training samples and 10,00010,000 validation samples, and use the standard MNIST testing set. For both the encoder and decoder, we use a simple architecture of 22 linear layers (detailed in the supplementary material).

MS-Celeb-1M dataset.

Next, we evaluate the ML-VAE on the face aligned version of the MS-Celeb-1M dataset Guo et al. (2016). The dataset was constructed by retrieving approximately 100100 images per celebrity from popular search engines, and noise has not been removed from the dataset. For each query, we consider the top ten results (note there was multiple queries per celebrity, therefore some identities have more than 1010 images). This creates a dataset of 98,88098,880 entities for a total of 811,792811,792 images, and we group the data by identity. Importantly, we randomly separate the dataset in disjoints sets of identities as the training, validation and testing datasets. This way we evaluate the ability of ML-VAE level to generalise to unseen groups (unseen identities) at test-time. The training dataset consists of 48,88048,880 identities (total 401,406401,406 images), the validation dataset consists of 25,00025,000 identities (total 205,015205,015 images) and the testing dataset consists of 25,00025,000 identities (total 205,371205,371 images). The encoder and the decoder network architectures, composed of either convolutional or deconvolutional and linear layers, are detailed in the supplementary material. We resize the images to 64×6464\times 64 pixels to fit the network architecture.

Qualitative Evaluation.

As explained in Mathieu et al. (2016), there is no standard benchmark dataset or metric to evaluate a model on its disentanglement performance. Therefore similarly to Mathieu et al. (2016) we perform qualitative and quantitative evaluations. We qualitatively assess the relevance of the learned representation by performing operations on the latent space. First we perform swapping: we encode test images, draw a sample per image from its style and content latent representations, and swap the style between images. Second we perform interpolation: we encode a pair of test images, draw one sample from each image style and content latent codes, and linearly interpolate between the style and content samples. We present the results of swapping and interpolation with accumulating evidence of 1010 other images in the group (strategy 22). Results without accumulated evidence (strategy 11) are also convincing and available in the supplementary material. We also perform generation: for a given test identity, we build the content latent code by accumulating images of this identity. Then take the mean of the resulting content distribution and generate images with styles sampled from the prior. Finally in order to explore the benefits of taking into account the grouping information, for a given test identity, we reconstruct all images for this identity using both these strategies and show the resulting images.

Figure 4 shows the swapping procedure, where the first row and the first column show the test data sample input to ML-VAE, second row and column are reconstructed samples. Each row is a fixed style and each column is a fixed content. We see that the ML-VAE disentangles the factors of variation of the data in a relevant manner. In the case of MS-Celeb-1M, we see that the model encodes the factor of variation that grouped the data, that is the identity, into the facial traits which remain constant when we change the style, and encodes the style into the remaining factors (background color, face orientation for example). The ML-VAE learns this meaningful disentanglement without the knowledge that the images are grouped by identity, but only the organisation of the data into groups. Figure 5 shows interpolation and generation. We see that our model covers the manifold of the data, and that style and content are disentangled. In Figures 6(a) and 6(b), we reconstruct images of the same group with and without taking into account the grouping information. We see that the ML-VAE handles cases where there is no group information at test-time, and benefits from accumulating evidence if available.

Quantitative Evaluation.

In order to quantitatively evaluate the disentanglement power of ML-VAE, we use the style latent code SS and content latent code CC as features for a classification task. The quality of the disentanglement is high if the content CC is informative about the class, while the style SS is not. In the case of MNIST the class is the digit label and for MS-Celeb-1M the class is the identity. We emphasise that in the case of MS-Celeb-1M test images are all unseen classes (unseen identities) at training. We learn to classify the test images with a neural network classifier composed of two linear layers of 256256 hidden units each, once using SS and once using CC as input features. Again we explore the benefits of accumulating evidence: while we construct the variational approximation on the content latent code by accumulating KK images per class for training the classifier, we accumulate only k≤Kk\leq K images per class at test time, where k=1k=1 corresponds to no group information. When kk increases we expect the performance of the classifer trained on CC to improve as the features become more informative and the performance using features SS to remain constant. We compare to the original VAE model, where we also accumulate evidence by using the Product of Normal method on the VAE latent code for samples of the same class. The results are shown in Figure 6(c). The ML-VAE content latent code is as informative about the class as the original VAE latent code, both in terms of classification accuracy and conditional entropy. ML-VAE also provides relevant disentanglement as the style remains uninformative about the class. Details on the choices of KK and this experiment are in the supplementary material.

Discussion

We proposed the Multi-Level VAE model for learning a meaningful disentanglement from a set of grouped observations. The ML-VAE model handles an arbitrary number of groups of observations, which needs not be the same at training and testing. We proposed different methods for incorporating the semantics embedded in the grouping. Experimental evaluation show the relevance of our method, as the ML-VAE learns a semantically meaningful disentanglement, generalises to unseen groups and enables control on the latent representation. For future work, we wish to apply the ML-VAE to text data.

References