GSN
Efficient implementation of Generative Stochastic Networks
view repo
Recent work has shown how denoising and contractive autoencoders implicitly capture the structure of the data-generating density, in the case where the corruption noise is Gaussian, the reconstruction error is the squared error, and the data is continuous-valued. This has led to various proposals for sampling from this implicitly learned density function, using Langevin and Metropolis-Hastings MCMC. However, it remained unclear how to connect the training procedure of regularized auto-encoders to the implicit estimation of the underlying data-generating distribution when the data are discrete, or using other forms of corruption process and reconstruction errors. Another issue is the mathematical justification which is only valid in the limit of small corruption noise. We propose here a different attack on the problem, which deals with all these issues: arbitrary (but noisy enough) corruption, arbitrary reconstruction loss (seen as a log-likelihood), handling both discrete and continuous-valued variables, and removing the bias due to non-infinitesimal corruption noise (or non-infinitesimal contractive penalty).
READ FULL TEXT VIEW PDFEfficient implementation of Generative Stochastic Networks
None
Auto-encoders learn an encoder function from input to representation and a decoder function back from representation to input space, such that the reconstruction (composition of encoder and decoder) is good for training examples. Regularized auto-encoders also involve some form of regularization that prevents the auto-encoder from simply learning the identity function, so that reconstruction error will be low at training examples (and hopefully at test examples) but high in general. Different variants of auto-encoders and sparse coding have been, along with RBMs, among the most successful building blocks in recent research in deep learning
(Bengio et al., 2013b). Whereas the usefulness of auto-encoder variants as feature learners for supervised learning can directly be assessed by performing supervised learning experiments with unsupervised pre-training, what has remained until recently rather unclear is the interpretation of these algorithms in the context of pure unsupervised learning, as devices to capture the salient structure of the input data distribution. Whereas the answer is clear for RBMs, it is less obvious for regularized auto-encoders. Do they completely characterize the input distribution or only some aspect of it? For example, clustering algorithms such as k-means only capture the modes of the distribution, while manifold learning algorithms characterize the low-dimensional regions where the density concentrates.
Some of the first ideas about the probabilistic interpretation of auto-encoders were proposed by Ranzato et al. (2008): they were viewed as approximating an energy function through the reconstruction error, i.e., being trained to have low reconstruction error at the training examples and high reconstruction error elsewhere (through the regularizer, e.g., sparsity or otherwise, which prevents the auto-encoder from learning the identity function). An important breakthrough then came, yielding a first formal probabilistic interpretation of regularized auto-encoders as models of the input distribution, with the work of Vincent (2011). This work showed that some denoising auto-encoders (DAEs) correspond to a Gaussian RBM and that minimizing the denoising reconstruction error (as a squared error) estimates the energy function through a regularized form of score matching, with the regularization disappearing as the amount of corruption noise goes to 0, and then converging to the same solution as score matching (Hyvärinen, 2005). This connection and its generalization to other energy functions, giving rise to the general denoising score matching training criterion, is discussed in several other papers (Kingma and LeCun, 2010; Swersky et al., 2011; Alain and Bengio, 2013).
Another breakthrough has been the development of an empirically successful sampling algorithm for contractive auto-encoders (Rifai et al., 2012)
, which basically involves composing encoding, decoding, and noise addition steps. This algorithm is motivated by the observation that the Jacobian matrix (of derivatives) of the encoding function provides an estimator of a local Gaussian approximation of the density, i.e., the leading singular vectors of that matrix span the tangent plane of the manifold near which the data density concentrates. However, a formal justification for this algorithm remains an open problem.
The last step in this development (Alain and Bengio, 2013) generalized the result from Vincent (2011) by showing that when a DAE (or a contractive auto-encoder with the contraction on the whole encode/decode reconstruction function) is trained with small Gaussian corruption and squared error loss, it estimates the score (derivative of the log-density) of the underlying data-generating distribution, which is proportional to the difference between reconstruction and input. This result does not depend on the parametrization of the auto-encoder, but suffers from the following limitations: it applies to one kind of corruption (Gaussian), only to continuous-valued inputs, only for one kind of loss (squared error), and it becomes valid only in the limit of small noise (even though in practice, best results are obtained with large noise levels, comparable to the range of the input).
What we propose here is a different probabilistic interpretation of DAEs, which is valid for any data type, any corruption process (so long as it has broad enough support), and any reconstruction loss (so long as we can view it as a log-likelihood).
The basic idea is that if we corrupt observed random variable
into using conditional distribution , we are really training the DAE to estimate the reverse conditional . Combining this estimator with the known , we show that we can recover a consistent estimator ofthrough a Markov chain that alternates between sampling from
and sampling from , i.e., encode/decode, sample from the reconstruction distribution model , apply the stochastic corruption procedure , and iterate.This theoretical result is validated through experiments on artificial data in a non-parametric setting and experiments on real data in a parametric setting (with neural net DAEs). We find that we can improve the sampling behavior by using the model itself to define the corruption process, yielding a training procedure that has some surface similarity to the contrastive divergence algorithm
(Hinton, 1999; Hinton et al., 2006).Let be the data-generating distribution over observed random variable . Let be a given corruption process that stochastically maps an to a through conditional distribution . The training data for the generalized denoising auto-encoder is a set of pairs with and . The DAE is trained to predict given through a learned conditional distribution , by choosing this conditional distribution within some family of distributions indexed by , not necessarily a neural net. The training procedure for the DAE can generally be formulated as learning to predict given by possibly regularized maximum likelihood, i.e., the generalization performance that this training criterion attempts to minimize is
(1) |
where the expectation is taken over the joint data-generating distribution
(2) |
We define the following pseudo-Gibbs Markov chain associated with :
(3) |
which can be initialized from an arbitrary choice . This is the process by which we are going to generate samples according to the model implicitly learned by choosing . We define the transition operator that defines a conditional distribution for given , independently of , so that the sequence of ’s forms a homogeneous Markov chain. If the asymptotic marginal distribution of the ’s exists, we call this distribution , and we show below that it consistently estimates .
Note that the above chain is not a proper Gibbs chain in general because there is no guarantee that and
are consistent with a unique joint distribution. In that respect, the situation is similar to the sampling procedure for dependency networks
(Heckerman et al., 2000), in that the pairs are not guaranteed to have the same asymptotic distribution as the pairs as . As a follow-up to the results in the next section, it is shown in Bengio et al. (2013a) that dependency networks can be cast into the same framework (which is that of Generative Stochastic Networks), and that if the Markov chain is ergodic, then its stationary distribution will define a joint distribution between the random variables (here that would be and ), even if the conditionals are not consistent with it.Normally we only have access to a finite number of training examples but as , the empirical training distribution approaches the data-generating distribution. To compensate for the finite training set, we generally introduce a (possibly data-dependent) regularizer and the actual training criterion is a sum over training examples ,
(4) |
where we allow the regularization coefficient to be chosen according to the number of training examples , with as . With we get that (i.e. converges to generalization error, Eq. 1), so consistent estimators of stay consistent. We define to be the minimizer of when given training examples.
We define to be the transition operator associated with (the parameter obtained by minimizing the training criterion with examples), and define to be the asymptotic distribution of the Markov chain generated by (if it exists). We also define be the operator of the Markov chain associated with the learned model as .
If is a consistent estimator of the true conditional distribution and defines an ergodic Markov chain, then as the number of examples , the asymptotic distribution of the generated samples converges to the data-generating distribution .
If is ergodic, then the Markov chain converges to a . Based on our definition of the “true” joint (Eq. 2), one obtains a conditional . This conditional, along with can be used to define a proper Gibbs chain where one alternatively samples from and from . Let be the corresponding “true” transition operator, which maps the -th sample to the -th in that chain. That is, . produces as asymptotic marginal distribution over (as we consider more samples from the chain) simply because is the marginal distribution of the joint to which the chain converges. By hypothesis we have that as . Note that is defined exactly as but with replaced by . Hence as .
Now let us convert the convergence of to into the convergence of to . We will exploit the fact that for the 2-norm, matrix and unit vector , . Consider and
the principal eigenvector of
, which, by the Perron-Frobenius theorem, corresponds to the asymptotic distribution . Since , . Hence , which implies that, where the last equality comes from the Perron-Frobenius theorem (the leading eigenvalue is 1). Since
, it implies that becomes the leading eigenvector of , i.e., the asymptotic distribution of the Markov chain, converges to the true data-generating distribution, , as . ∎Hence the asymptotic sampling distribution associated with the Markov chain defined by (i.e., the model) implicitly defines the distribution learned by the DAE over the observed variable . Furthermore, that estimator of is consistent so long as our (regularized) maximum likelihood estimator of the conditional is also consistent. We now provide sufficient conditions for the ergodicity of the chain operator (i.e. to apply theorem 1).
If is a consistent estimator of the true conditional distribution , and both the data-generating distribution and denoising model are contained in and non-zero in a finite-volume region (i.e., , ), and , , and these statements remain true in the limit of , then the asymptotic distribution of the generated samples converges to the data-generating distribution .
To obtain the existence of a stationary distribution, it is sufficient to have irreducibility (every value reachable from every other value), aperiodicity (no cycle where only paths through the cycle allow to return to some value), and recurrence (probability 1 of returning eventually). These conditions can be generalized to the continuous case, where we obtain ergodic Harris chains rather than ergodic Markov chains. If
and (for ), then as well, becauseThis positivity of the transition operator guarantees that one can jump from any point in to any other point in one step, thus yielding irreducibility and aperiodicity. To obtain recurrence (preventing the chain from diverging to infinity), we rely on the assumption that the domain is bounded. Note that although could be true for any finite , we need this condition to hold for as well, to obtain the consistency result of theorem 1. By assuming this positivity (Boltzmann distribution) holds for the data-generating distribution, we make sure that does not converge to a distribution which puts 0’s anywhere in . Having satisfied all the conditions for the existence of a stationary distribution for as , we can apply theorem 1 and obtain its conclusion. ∎
Note how these conditions take care of the various troubling cases one could think of. We avoid the case where there is no corruption (which would yield a wrong estimation, with the DAE simply learning a dirac probability its input). Second, we avoid the case where the chain wanders to infinity by assuming a finite volume where the model and data live, a real concern in the continuous case. If it became a real issue, we could perform rejection sampling to make sure that produces .
If we believe that is well estimated for all pairs, i.e., that it is approximately consistent with , then we get as many estimators of the energy function as we want, by picking a particular value of .
Let us define the notation to denote the probability of the joint, marginals or conditionals over the pairs that are produced by the model’s Markov chain as . So is the asymptotic distribution of the Markov chain , and the marginal over the ’s in that chain. The above assumption means that (which is not guaranteed in general, but only asymptotically as approaches the true ). Then, by Bayes rule, so that we can get an estimated energy function from any given choice of through . where one should note that the intractable partition function depends on the chosen value of .
How much can we trust that estimator and how should be chosen? First note that has only been trained for pairs for which is relatively close to (assuming that the corruption is indeed changing generally into some neighborhood). Hence, although in theory (with infinite amount of data and capacity) the above estimator should be good, in practice it might be poor when is far from . So if we pick a particular the estimated energy might be good for in the neighborhood of but poor elsewhere. What we could do though, is use a different approximate energy function in different regions of the input space. Hence the above estimator gives us a way to compare the probabilities of nearby points and (through their difference in energy), picking for example a midpoint . One could also imagine that if and are far apart, we could chart a path between and with intermediate points and use an estimator of the relative energies between the neighbors , add them up, and obtain an estimator of the relative energy between and .
This brings up an interesting point. If we could always obtain a good estimator for any , we could just train the model with , i.e., with an unconditional noise process that ignores . In that case, the estimator would directly equal since and are actually sampled independently in its “denoising” training data. We would have gained nothing over just training any probabilistic model just directly modeling the observed ’s. The gain we expect from using the denoising framework is that if is a local perturbation of , then the true can be well approximated by a much simpler distribution than . See Figure 1 for a visual explanation: in the limit of very small perturbations, one could even assume that can be well approximated by a simple unimodal distribution such as the Gaussian (for continuous data) or factorized binomial (for discrete binary data) commonly used in DAEs as the reconstruction probability function (conditioned on ). This idea is already behind the non-local manifold Parzen windows (Bengio et al., 2006a) and non-local manifold tangent learning (Bengio et al., 2006b) algorithms: the local density around a point can be approximated by a multivariate Gaussian whose covariance matrix has leading eigenvectors that span the local tangent of the manifold near which the data concentrates (if it does). The idea of a locally Gaussian approximation of a density with a manifold structure is also exploited in the more recent work on the contractive auto-encoder (Rifai et al., 2011) and associated sampling procedures (Rifai et al., 2012). Finally, strong theoretical evidence in favor of that idea comes from the result from Alain and Bengio (2013): when the amount of corruption noise converges to 0 and the input variables have a smooth continuous density, then a unimodal Gaussian reconstruction density suffices to fully capture the joint distribution.
Hence, although encapsulates all information about (assuming given), it will generally have far fewer non-negligible modes, making easier to approximate it. This can be seen analytically by considering the case where is a mixture of many Gaussians and the corruption is a local Gaussian: remains a Gaussian mixture, but one for which most of the modes have become negligible (Alain and Bengio, 2013). We return to this in Section 3, suggesting that in order to avoid spurious modes, it is better to have non-infinitesimal corruption, allowing faster mixing and successful burn-in not pulled by spurious modes far from the data.
Sampling in high-dimensional spaces (like in experiments below) using a simple local corruption process (such as Gaussian or salt-and-pepper noise) suggests that if the corruption is too local, the DAE’s behavior far from the training examples can create spurious modes in the regions insufficiently visited during training. More training iterations or increasing the amount of corruption noise helps to substantially alleviate that problem, but we discovered an even bigger boost by training the DAE Markov chain to walk back towards the training examples (see Figure 2).
We exploit knowledge of the currently learned model to define the corruption, so as to pick values of that would be obtained by following the generative chain: wherever the model would go if we sampled using the generative Markov chain starting at a training example , we consider to be a kind of “negative example” from which the auto-encoder should move away (and towards ). The spirit of this procedure is thus very similar to the CD- (Contrastive Divergence with MCMC steps) procedure proposed to train RBMs (Hinton, 1999; Hinton et al., 2006).
More precisely, the modified corruption process we propose is the following, based on the original corruption process . We use it in a version of the training algorithm called walkback, where we replace the corruption process of Algorithm 1 by the walkback process of Algorithm 3. This also provides extra training examples (taking advantage of the samples generated along the walk away from ). It is called walkback because it forces the DAE to learn to walk back from the random walk it generates, towards the ’s in the training set.
Let be the implicitly defined asymptotic distribution of the Markov chain alternating sampling from and , where is the original local corruption process. Under the assumptions of corollary 1, minimizing the training criterion in walkback training algorithm for generalized DAEs (combining Algorithms 1 and 3) produces a that is a consistent estimator of the data generating distribution .
Consider that during training, we produce a sequence of estimators where corresponds to the -th training iteration (modifying the parameters after each iteration). With the walkback algorithm, is used to obtain the corrupted samples from which the next model is produced. If training converges, and we can then consider the whole corruption process fixed. By corollary 1, the Markov chain obtained by alternating samples from and samples from converges to an asymptotic distribution which estimates the underlying data-generating distribution . The walkback corruption corresponds to a few steps alternating sampling from (the fixed local corruption) and sampling from . Hence the overall sequence when using can be seen as a Markov chain obtained by alternatively sampling from and from just as it was when using merely . Hence, once the model is trained with walkback, one can sample from it usingc orruption . ∎
A consequence is that the walkback training algorithm estimates the same distribution as the original denoising algorithm, but may do it more efficiently (as we observe in the experiments), by exploring the space of corruptions in a way that spends more time where it most helps the model.
Non-parametric case. The mathematical results presented here apply to any denoising training criterion where the reconstruction loss can be interpreted as a negative log-likelihood. This remains true whether or not the denoising machine is parametrized as the composition of an encoder and decoder. This is also true of the asymptotic estimation results in Alain and Bengio (2013). We experimentally validate the above theorems in a case where the asymptotic limit (of enough data and enough capacity) can be reached, i.e., in a low-dimensional non-parametric setting. Fig. 3 shows the distribution recovered by the Markov chain for discrete data with only 10 different values. The conditional was estimated by multinomial models and maximum likelihood (counting) from 5000 training examples. 5000 samples were generated from the chain to estimate the asymptotic distribution . For continuous data, Figure 3 also shows the result of 5000 generated samples and 500 original training examples with , with scatter plots of pairs of dimensions. The estimator is also non-parametric (Parzen density estimator of ).
MNIST digits.
We trained a DAE on the binarized MNIST data (thresholding at 0.5). A Theano
^{1}^{1}1http://deeplearning.net/software/theano/ (Bergstra et al., 2010) implementation is available^{2}^{2}2git@github.com:yaoli/GSN.git. The 784-2000-784 auto-encoder is trained for 200 epochs with the 50000 training examples and salt-and-pepper noise (probability 0.5 of corrupting each bit, setting it to 1 or 0 with probability 0.5). It has 2000 tanh hidden units and is trained by minimizing cross-entropy loss, i.e., maximum likelihood on a factorized Bernoulli reconstruction distribution. With walkback training, a chain of 5 steps was used to generate 5 corrupted examples for each training example. Figure
4 shows samples generated with and without walkback. The quality of the samples was also estimated quantitatively by measuring the log-likelihood of the test set under a non-parametric density estimator constructed from 10000 consecutively generated samples ( from the Markov chain). The expected value of over the samples can be shown (Bengio and Yao, 2013) to be a lower bound (i.e. conservative estimate) of the true (implicit) model density . The test set log-likelihood bound was not used to select among model architectures, but visual inspection of samples generated did guide the preliminary search reported here. Optimization hyper-parameters (learning rate, momentum, and learning rate reduction schedule) were selected based on the training objective. We compare against a state-of-the-art RBM (Cho et al., 2013) with an AIS log-likelihood estimate of -64.1 (AIS estimates tend to be optimistic). We also drew samples from the RBM and applied the same estimator (using the mean of the RBM’s with sampled from the Gibbs chain), and obtained a log-likelihood non-parametric bound of -233, skipping 100 MCMC steps between samples (otherwise numbers are very poor for the RBM, which does not mix at all). The DAE log-likelihood bound with and without walkback is respectively -116 and -142, confirming visual inspection suggesting that the walkback algorithm produces less spurious samples. However, the RBM samples can be improved by a spatial blur. By tuning the amount of blur (the spread of the Gaussian convolution), we obtained a bound of -112 for the RBM. Blurring did not help the auto-encoder.We have proven that training a model to denoise is a way to implicitly estimate the underlying data-generating process, and that a simple Markov chain that alternates sampling from the denoising model and from the corruption process converges to that estimator. This provides a means for generating data from any DAE (if the corruption is not degenerate, more precisely, if the above chain converges). We have validated those results empirically, both in a non-parametric setting and with real data. This study has also suggested a variant of the training procedure, walkback training, which seem to converge faster to same the target distribution.
One of the insights arising out of the theoretical results presented here is that in order to reach the asymptotic limit of fully capturing the data distribution , it may be necessary for the model’s to have the ability to represent multi-modal distributions over (given ).
Enhanced gradient for training restricted boltzmann machines.
Neural computation, 25(3), 805–831.Dependency networks for inference, collaborative filtering, and data visualization.
Journal of Machine Learning Research
, 1, 49–75.Sparse feature learning for deep belief networks.
In NIPS’07, pages 1185–1192, Cambridge, MA. MIT Press.Contractive auto-encoders: Explicit invariance during feature extraction.
In ICML’2011.On autoencoders and score matching for energy based models.
In ICML’2011. ACM.A connection between score matching and denoising autoencoders.
Neural Computation, 23(7).