Project for experimenting with tensor flow
Deep generative models parameterized by neural networks have recently achieved state-of-the-art performance in unsupervised and semi-supervised learning. We extend deep generative models with auxiliary variables which improves the variational approximation. The auxiliary variables leave the generative model unchanged but make the variational distribution more expressive. Inspired by the structure of the auxiliary variable we also propose a model with two stochastic layers and skip connections. Our findings suggest that more expressive and properly specified deep generative models converge faster with better results. We show state-of-the-art performance within semi-supervised learning on MNIST, SVHN and NORB datasets.READ FULL TEXT VIEW PDF
This note compares two recently published machine learning methods for
In this paper we develop Neural Random Field learning with
The lottery ticket hypothesis suggests that sparse, sub-networks of a gi...
We introduce a novel objective for training deep generative time-series
We introduce deep involutive generative models, a new architecture for d...
We assume that a high-dimensional datum, like an image, is a composition...
A deep generative model such as a GAN learns to model a rich set of sema...
Project for experimenting with tensor flow
Recently there have been significant improvements within the semi-supervised classification tasks. Kingma et al. (2014)
introduced a deep generative model for semi-supervised learning by modeling the joint distribution over data and labels. This model is difficult to train end-to-end with more than one layer of stochastic latent variables, but coupled with a pretrained feature extractor it performs well. Lately the Ladder network(Rasmus et al., 2015; Valpola, 2014) and virtual adversarial training (VAT) (Miyato et al., 2015) have improved the performance further with end-to-end training.
In this paper we train deep generative models with multiple stochastic layers. The Auxiliary Deep Generative Models (ADGM) utilize an extra set of auxiliary latent variables to increase the flexibility of the variational distribution (cf. Sec. 2.2). We also introduce a slight change to the ADGM, a 2-layered stochastic model with skip connections, the Skip Deep Generative Model (SDGM) (cf. Sec. 2.4). Both models are trainable end-to-end and offer state-of-the-art performance when compared to other semi-supervised methods. In the paper we first introduce toy data to demonstrate that:
By fitting a complex half-moon dataset using only six labeled data points the ADGM utilizes the data manifold for semi-supervised classification (cf. Sec. 4.2).
For the benchmark datasets we show (cf. Sec. 4.4):
State-of-the-art results on several semi-supervised classification tasks.
That multi-layered deep generative models for semi-supervised learning are trainable end-to-end without pre-training or feature engineering.
Recently Kingma (2013); Rezende et al. (2014) have coupled the approach of variational inference with deep learning giving rise to powerful probabilistic models constructed by an inference neural network and a generative neural network . This approach can be perceived as a variational equivalent to the deep auto-encoder, in which acts as the encoder and the decoder. However, the difference is that these models ensures efficient inference over continuous distributions in the latent space with automatic relevance determination and regularization due to the KL-divergence. Furthermore, the gradients of the variational upper bound are easily defined by backpropagation through the network(s). To keep the computational requirements low the variational distribution is usually chosen to be a diagonal Gaussian, limiting the expressive power of the inference model.
In this paper we propose a variational auxiliary variable approach (Agakov and Barber, 2004) to improve the variational distribution: The generative model is extended with variables to such that the original model is invariant to marginalization over : . In the variational distribution, on the other hand, is used such that marginal
is a general non-Gaussian distribution. This hierarchical specification allows the latent variables to be correlated through, while maintaining the computational efficiency of fully factorized models (cf. Fig. 1). In Sec. 4.1 we demonstrate the expressive power of the inference model by fitting a complex multimodal distribution.
The variational auto-encoder (VAE) has recently been introduced as a powerful method for unsupervised learning. Here a latent variable generative modelfor data is parameterized by a deep neural network with parameters . The parameters are inferred by maximizing the variational lower bound of the likelihood with
The inference model is parameterized by a second deep neural network. The inference and generative parameters, and , are jointly trained by optimizing Eq. 2.1 with stochastic gradient ascent, where we use the reparameterization trick for backpropagation through the Gaussian latent variables (Kingma, 2013; Rezende et al., 2014).
We propose to extend the variational distribution with auxiliary variables : such that the marginal distribution can fit more complicated posteriors . In order to have an unchanged generative model, , it is required that the joint mode gives back the original under marginalization over , thus . Auxiliary variables are used in the EM algorithm and Gibbs sampling and have previously been considered for variational learning by Agakov and Barber (2004). Concurrent with this work Ranganath et al. (2015) have proposed to make the parameters of the variational distribution stochastic, which leads to a similar model. It is important to note that in order not to fall back to the original VAE model one has to require , see Agakov and Barber (2004) and App. A. The auxiliary VAE lower bound becomes
with and diagonal Gaussian distributions parameterized by deep neural networks.
The main focus of this paper is to use the auxiliary approach to build semi-supervised models that learn classifiers from labeled and unlabeled data. To encompass the class information we introduce an extra latent variable. The generative model is defined as (cf. Fig. 0(a)):
where , , are the auxiliary variable, class label, and latent features, respectively. is a multinomial distribution, where is treated as a latent variable for the unlabeled data points. In this study we only experimented with categorical labels, however the method applies to other distributions for the latent variable . is iid categorical or Gaussian for discrete and continuous observations . are deep neural networks with parameters . The inference model is defined as (cf. Fig. 0(b)):
In order to model Gaussian distributions , , and we define two separate outputs from the top deterministic layer in each deep neural network, and . From these outputs we are able to approximate the expectations by applying the reparameterization trick.
The key point of the ADGM is that the auxiliary unit introduce a latent feature extractor to the inference model giving a richer mapping between and . We can use the classifier (9
) to compute probabilities for unlabeled data
being part of each class and to retrieve a cross-entropy error estimate on the labeled data. This can be used in cohesion with the variational lower bound to define a good objective function in order to train the model end-to-end.
We optimize the model by maximizing the lower bound on the likelihood (cf. App. B for more details). The variational lower bound on the marginal likelihood for a single labeled data point is
with . For unlabeled data we further introduce the variational distribution for , :
The classifier (9) appears in , but not in . The classification accuracy can be improved by introducing an explicit classification loss for labeled data:
where is a weight between generative and discriminative learning. The parameter is set to , where is a scaling constant, is the number of labeled data points and is the number of unlabeled data points. The objective function for labeled and unlabeled data is
Kingma et al. (2014) proposed a model with two stochastic layers but were unable to make it converge end-to-end and instead resorted to layer-wise training. In our preliminary analysis we also found that this model: failed to converge when trained end-to-end. On the other hand, the auxiliary model can be made into a two-layered stochastic model by simply reversing the arrow between and in Fig. 0(a). We would expect that if the auxiliary model works well in terms of convergence and performance then this two-layered model ( is now part of the generative model): should work even better because it is a more flexible generative model. The variational distribution is unchanged: . We call this the Skip Deep Generative Model (SDGM) and test it alongside the auxiliary model in the benchmarks (cf. Sec. 4.4).
The SDGM and ADGM are each parameterized by 5 neural networks (NN): (1) auxiliary inference model , (2) latent inference model , (3) classification model , (4) generative model , and (5) the generative model .
The neural networks consists of fully connected hidden layers with denoting the output of a layer
. All hidden layers use rectified linear activation functions. To compute the approximations of the stochastic variables we place two independent output layers after, and . In a forward-pass we are propagating the input through the neural network by
with denoting a linear activation function. We then approximate the stochastic variables by applying the reparameterization trick using the and outputs.
For all the benchmark experiments (cf. Sec. 4.4) we parameterized the deep neural networks with two fully connected hidden layers. Each pair of hidden layers was of size or with or . The generative model was for the ADGM and the SDGM had the augmented . Both have unchanged inference models (cf. Fig. 0(b)).
All parameters are initialized using the Glorot and Bengio (2010) scheme. The expectation over the and variables were performed by Monte Carlo sampling using the reparameterization trick (Kingma, 2013; Rezende et al., 2014) and the average over by exact enumeration so
with and .
For training, we have used the Adam (Kingma and Ba, 2014)
optimization framework with a learning rate of 3e-4, exponential decay rate for the 1st and 2nd moment atand , respectively. The constant was between and throughout the experiments.
The models are implemented in Python using Theano(Bastien et al., 2012), Lasagne (Dieleman et al., 2015) and Parmesan libraries111Implementation is available in a repository named auxiliary-deep-generative-models on github.com..
For the MNIST dataset we have combined the training set of examples with the validation set of examples. The test set remained as is. We used a batch size of with half of the batch always being the
labeled samples. The labeled data are chosen randomly, but distributed evenly across classes. To speed up training, we removed the columns with a standard deviation belowresulting in an input size of
For the SVHN dataset we used the vectorized and cropped training setwith classes from to , combined with the extra set resulting in data points. The test set is of size . We trained on the small NORB dataset consisting of training samples and an equal amount of test samples distributed across 5 classes: animal, human, plane, truck, car. We normalized all NORB images following Miyato et al. (2015) using image pairs of resulting in a vectorized input of . The labeled subsets consisted of evenly distributed labeled samples. The batch size for SVHN was and for NORB , where half of the batch was labeled samples. To avoid the phenomenon on modeling discretized values with a real-valued estimation (Uria et al., 2013), we added uniform noise between 0 and 1 to each pixel value. We normalized the NORB dataset by and the SVHN dataset by the standard deviation on each color channel. Both datasets were assumed Gaussian distributed for the generative models .
In this section we present two toy examples that shed light on how the auxiliary variables improve the distribution fit. Thereafter we investigate the unsupervised generative log-likelihood performance followed by semi-supervised classification performance on several benchmark datasets. We demonstrate state-of-the-art performance and show that adding auxiliary variables increase both classification performance and convergence speed (cf. Sec. 3 for details).
In variational auto-encoders the inference model is parameterized as a fully factorized Gaussian. We demonstrate that the auxiliary model can fit complicated posterior distributions for the latent space. To do this we consider the 2D potential model (Rezende and Mohamed, 2015) that leads to the bound
Fig. 1(a) shows the true posterior and Fig. 1(b) shows a density plot of samples from and from a trained ADGM. This is similar to the findings of Rezende and Mohamed (2015) in which they demonstrate that by using normalizing flows they can fit complicated posterior distributions. The most frequent solution found in optimization is not the one shown, but one where fits only one of the two equivalent modes. The one and two mode solution will have identical values of the bound so it is to be expected that the simpler single mode solution will be easier to infer.
To exemplify the power of the ADGM for semi-supervised learning we have generated a 2D synthetic dataset consisting of two half-moons (top and bottom), where and , with added Gaussian noise. The training set contains 1e4 samples divided into batches of 100 with labeled data points in each class and the test set contains 1e4 samples. A good semi-supervised model will be able to learn the data manifold for each of the half-moons and use this together with the limited labeled information to build the classifier.
The ADGM converges close to classification error in 10 epochs (cf. Fig. 1(c)), which is much faster than an equivalent model without the auxiliary variable that converges in more than epochs. When investigating the auxiliary variable we see that it finds a discriminating internal representation of the data manifold and thereby aids the classifier (cf. Fig. 1(d)).
We evaluate the generative performance of the unsupervised auxiliary model, AVAE, using the MNIST dataset. The inference and generative models are defined as
where denotes the number of stochastic layers.
We report the lower bound from Eq. (2.2) for 5000 importance weighted samples and use the same training and parameter settings as in Sønderby et al. (2016) with warm-up222Temperature on the KL-divergence going from 0 to 1 within the first 200 epochs of training.
, batch normalization and 1 Monte Carlo and IW sample for training.
|VAE+NF, L=1 (Rezende and Mohamed, 2015)|
|IWAE, L=1, IW=1 (Burda et al., 2015)|
|IWAE, L=1, IW=50 (Burda et al., 2015)|
|IWAE, L=2, IW=1 (Burda et al., 2015)|
|IWAE, L=2, IW=50 (Burda et al., 2015)|
|VAE+VGP, L=2 (Tran et al., 2015)|
|LVAE, L=5, IW=1 (Sønderby et al., 2016)|
|LVAE, L=5, FT, IW=10 (Sønderby et al., 2016)|
|Auxiliary VAE (AVAE), L=1, IW=1|
|Auxiliary VAE (AVAE), L=2, IW=1|
|M1+TSVM (Kingma et al., 2014)||% ()||% ()||% ()|
|M1+M2 (Kingma et al., 2014)||% ()||%()||-|
|VAT (Miyato et al., 2015)||%||%||%|
|Ladder Network (Rasmus et al., 2015)||% ()||-||-|
|Auxiliary Deep Generative Model (ADGM)||0.96% ()||%||% ()|
|Skip Deep Generative Model (SDGM)||% ()||16.61% ()||9.40% ()|
We evaluate the negative log-likelihood for the 1 and 2 layered AVAE. We found that warm-up was crucial for activation of the auxiliary variables. Table 1 shows log-likelihood scores for the permutation invariant MNIST dataset. The methods are not directly comparable, except for the Ladder VAE (LVAE) (Sønderby et al., 2016), since the training is performed differently. However, they give a good indication on the expressive power of the auxiliary variable model. The AVAE is performing better than the VAE with normalizing flows (Rezende and Mohamed, 2015) and the importance weighted auto-encoder with 1 IW sample (Burda et al., 2015). The results are also comparable to the Ladder VAE with 5 latent layers (Sønderby et al., 2016) and variational Gaussian process VAE (Tran et al., 2015). As shown in Burda et al. (2015) and Sønderby et al. (2016) increasing the IW samples and annealing the learning rate will likely increase the log-likelihood.
Table 2 shows the performance of the ADGM and SDGM on the MNIST dataset. The ADGM’s convergence to around 2% is fast (around 200 epochs), and from that point the convergence speed declines and finally reaching % (cf. Fig. 5). The SDGM shows close to similar performance and proves more stable by speeding up convergence, due to its more advanced generative model. We achieved the best results on MNIST by performing multiple Monte Carlo samples for and .
A good explorative estimate of the models ability to comprehend the data manifold, or in other words be as close to the posterior distribution as possible, is to evaluate the generative model. In Fig. 2(a) we show how the SDGM, trained on only 100 labeled data points, has learned to separate style and class information. Fig 2(b) shows random samples from the generative model.
Fig. 3(a) demonstrate the information contribution from the stochastic unit and (subscripts and denotes a unit) in the SDGM as measured by the average over the test set of the KL-divergence between the variational distribution and the prior. Units with little information content will be close to the prior distribution and the KL-divergence term will thus be close to 0. The number of clearly activated units in and is quite low , but there is a tail of slightly active units, similar results have been reported by Burda et al. (2015). It is still evident that we have information flowing through both variables though. Fig. 1(d) and 3(b) shows clustering in the auxiliary space for both the ADGM and SDGM respectively.
In order to investigate whether the stochasticity of the auxiliary variable or the network depth is essential to the models performance, we constructed an ADGM with a deterministic auxiliary variable. Furthermore we also implemented the M2 model of Kingma et al. (2014)
using the exact same hyperparameters as for learning the ADGM. Fig.5 shows how the ADGM outperforms both the M2 model and the ADGM with deterministic auxiliary variables. We found that the convergence of the M2 model was highly unstable; the one shown is the best obtained.
From Table 2 we see how the SDGM outperforms VAT with a relative reduction in error rate of more than % on the SVHN dataset. We also tested the model performance, when we omitted the SVHN extra set from training. Here we achieved a classification error of %. The improvements on the NORB dataset was not as significant as for SVHN with the ADGM being slightly worse than VAT and the SDGM being slightly better than VAT.
On SVHN the model trains to around % classification error in 100 epochs followed by a decline in convergence speed. The NORB dataset is a significantly smaller dataset and the SDGM converges to around % in 100 epochs. We also trained the NORB dataset on single images as opposed to image pairs (half the dataset) and achieved a classification error around % in 100 epochs.
For Gaussian input distributions, like the image data of SVHN and NORB, we found the SDGM to be more stable than the ADGM.
The ADGM and SDGM are powerful deep generative models with relatively simple neural network architectures. They are trainable end-to-end and since they follow the principles of variational inference there are multiple improvements to consider for optimizing the models like using the importance weighted bound or adding more layers of stochastic variables. Furthermore we have only proposed the models using a Gaussian latent distribution, but the model can easily be extended to other distributions (Ranganath et al., 2014, 2015).
One way of approaching the stability issues of the ADGM, when training on Gaussian input distributions is to add a temperature weighting between discriminative and stochastic learning on the KL-divergence for and when estimating the variational lower bound (Sønderby et al., 2016). We find similar problems for the Gaussian input distributions in van den Oord et al. (2016), where they restrict the dataset to ordinal values in order to apply a softmax function for the output of the generative model . This discretization of data is also a possible solution. Another potential stabilizer is to add batch normalization (Ioffe and Szegedy, 2015) that will ensure normalization of each output batch of a fully connected hidden layer.
A downside to the semi-supervised variational framework is that we are summing over all classes in order to evaluate the variational bound for unlabeled data. This is a computationally costly operation when the number of classes grow. In this sense, the Ladder network has an advantage. A possible extension is to sample when calculating the unlabeled lower bound
, but this may result in gradients with high variance.
The framework is implemented with fully connected layers. VAEs have proven to work well with convolutional layers so this could be a promising step to further improve the performance. Finally, since we expect that the variational bound found by the auxiliary variable method is quite tight, it could be of interest to see whether the bound for may be used for classification in the Bayes classifier manner .
We have introduced a novel framework for making the variational distributions used in deep generative models more expressive. In two toy examples and the benchmarks we investigated how the framework uses the auxiliary variables to learn better variational approximations. Finally we have demonstrated that the framework gives state-of-the-art performance in a number of semi-supervised benchmarks and is trainable end-to-end.
In this appendix we study the theoretical optimum of the auxiliary variational bound found by functional derivatives of the variational objective. In practice we will resort to restricted deep network parameterized distributions. But this analysis nevertheless shed some light on the properties of the optimum. Without loss of generality we consider only auxiliary and latent : , and . The results can be extended to the full semi-supervised setting without changing the overall conclusion. The variational bound for the auxiliary model is
We can now take the functional derivative of the bound with respect to . This gives the optimum , which in general is intractable because it requires marginalization: .
One may also restrict the generative model to an uninformed -model: . Optimizing with respect to we find . When we insert this solution into the variational bound we get
The solution to the optimization with respect to will simply be a -function at the value of that optimizes the variational bound for the -model. So we fall back to a model for without the auxiliary as also noted by Agakov and Barber (2004).
We have tested the uninformed auxiliary model in semi-supervised learning for the benchmarks and we got competitive results for MNIST but not for the two other benchmarks. We attribute this to two factors: in semi-supervised learning we add an additional classification cost so that the generic form of the objective is
we keep fixed to a zero mean unit variance Gaussian and we use deep iid models for , and . This taken together can lead to at least a local optimum which is different from the collapse to the pure -model.
In this appendix we give an overview of the variational objectives used. The generative model for the Auxiliary Deep Generative Model and the Skip Deep Generative Model are defined as
The lower bound on the labeled log-likelihood is defined as
where . We define the function to be . In the lower bound for the unlabeled data we treat the discrete 333 is assumed to be multinomial but the model can easily be extended to different distributions. as a latent variable. We rewrite the lower bound in the form of Kingma et al. (2014):
We thank Durk P. Kingma and Shakir Mohamed for helpful discussions. This research was supported by the Novo Nordisk Foundation, Danish Innovation Foundation and the NVIDIA Corporation with the donation of TITAN X and Tesla K40 GPUs.
Proceedings of the International Conference on Artificial Intelligence and Statistics (AISTATS’10)., pages 249–256.
Proceedings of International Conference of Machine Learning, pages 448–456.