L AGGING I NFERENCE N ETWORKS AND P OSTERIOR C OLLAPSE IN V ARIATIONAL A UTOENCODERS
A BSTRACT
The variational autoencoder (VAE) is a popular combination of deep latent variable model and accompanying variational learning technique.
By using a neural inference network to approximate the model’s posterior on latent variables, VAEs efﬁciently parameterize a lower bound on marginal data likelihood that can be optimized directly via gradient methods.
In practice, however, VAE training often results in a degenerate local optimum known as “posterior collapse” where the model learns to ignore the latent variable and the approximate posterior mimics the prior.
In this paper, we investigate posterior collapse from the perspective of training dynamics.
We ﬁnd that during the initial stages of training the inference network fails to approximate to the model’s true posterior, which is a moving target.
As a result, the model is encouraged to ignore the latent encoding and posterior collapse results.
Based on this observation, we propose an extremely simple modiﬁcation to VAE training to reduce inference lag: depending on the model’s current mutual information between latent variable and observation, we aggressively optimize the inference network before performing each model update.
Despite introducing neither new model components nor signiﬁcant complexity over basic VAE, our approach is able to avoid the problem of collapse that has plagued a large amount of previous work.
Empirically, our approach outperforms strong autoregressive baselines on text and image benchmarks in terms of held-out likelihood, and is competitive with more complex techniques for avoiding collapse, while being substantially faster.
I NTRODUCTION
Variational autoencoders (VAEs) (Kingma & Welling, 2014) represent a popular combination of a deep latent variable model (shown in Figure 1(a)) and an accompanying variational learning technique.
The generative model in VAE deﬁnes a marginal distribution on observations, x ∈ X , as:
[Equation]
The model’s generator deﬁnes p θ ( x | z ) and is typically parameterized as a complex neural network.
Standard training involves optimizing an evidence lower bound (ELBO) on the intractable marginal data likelihood (Eq.1), where an auxiliary variational distribution q φ ( z | x ) is introduced to approximate the model posterior distribution p θ ( z | x ) .
VAEs make this learning procedure highly scalable to large datasets by sharing parameters in the inference network to amortize the cost.
This amortization is in contrast to traditional variational inference that has separate local variational parameters for every data point (Blei et al., 2003; Hoffman et al., 2013).
While successful on some datasets, prior works has found that VAE training often suffers from “posterior collapse”, in which the model ignores the latent variable z when the generator
p θ ( x | z ) is parametrized using a strong autoregressive neural network such as LSTMs for text and PixelCNNs (van den Oord et al., 2016) for images (Bowman et al., 2016;
Chen et al., 2017; Kingma et al., 2016; Yang et al., 2017; Dieng et al., 2018).
Posterior collapse is especially evident when modeling
[Table]
+rcxaQFtoG+2iFjpAbXSOOqiLKHpEz+gFvTpPzrvz4XyOpVNO1bOJfoXz9Q0lJbMX</latexit>
[Figure]
discrete data, which hinders the usage of VAEs in important applications like natural language processing.
Existing work analyze this problem from a static optimization perspective noting that the collapsed solution is often a reasonably good local optimum in terms of ELBO (Chen et al., 2017;
Zhao et al., 2017; Alemi et al., 2018).
Thus, many proposed solutions to posterior collapse focus on weakening the generator by replacing it with a non-recurrent alternative (Yang et al., 2017; Semeniuta et al., 2017) or modifying the training objective (Zhao et al., 2017; Tolstikhin et al., 2018).
In this paper, we try to analyze the problem from perspective of training dynamics, and propose a novel training procedure for VAEs that optimizes the standard ELBO objective without changing the model structure.
Recently Kim et al.
(2018) proposed a new approach to training VAEs by composing the standard inference network with additional mean-ﬁeld updates.
The resulting semi-amortized approach empirically avoided collapse and obtained better ELBO.
However, because of the costly instancespeciﬁc local inference steps, the new method is more than 10x slower than basic VAE training in practice.
It is also unclear why the basic VAE method fails to ﬁnd better local optima that make use of latents.
We consider two questions in this paper: (1) Why does basic VAE training often fall into undesirable collapsed local optima?
(2) Is there a simpler way to change the training trajectory to ﬁnd a better non-trivial local optimum?
To this end, we ﬁrst study the posterior collapse problem from the perspective of training dynamics, and empirically ﬁnd that the approximate posterior is lagging far behind the true model posterior in the initial stages of training (Section 3).
We then demonstrate empirically how such lagging behavior can drive the generative model towards a collapsed local optimum, and propose a novel training procedure for VAEs that aggressively optimizes the inference network with more updates to mitigate the lagging issue (Section 4).
Without introducing new modeling components over basic
VAEs or additional complexity, our approach is surprisingly simple yet effective in circumventing posterior collapse.
As a density estimator it outperforms neural autoregressive baselines on both text (Yahoo and Yelp) and image (OMNIGLOT) benchmarks, leading to comparable performance with more complicated previous state-of-the-art methods at a fraction of the training cost (Section 6).
B ACKGROUND 2. V ARIATIONAL A UTOENCODERS
VAEs learn deep generative models deﬁned by a prior p ( z ) and a conditional distribution p θ ( x | z ) as shown in Figure 1(a).
In most cases the marginal data likelihood is intractable, so VAEs instead optimize a tractable variational lower bound (ELBO) of log p θ ( x ) ,
[Equation]
where q φ ( z | x ) is a variational distribution parameterized by an inference network with parameters φ , and p θ ( x | z ) denotes the generator network with parameters θ .
q φ ( z | x ) is optimized to approximate the model posterior p θ ( z | x ) .
This lower bound is composed of a reconstruction loss term that encourages the inference network to encode information necessary to generate the data and a KL regularizer to push q φ ( z | x ) towards the prior p ( z ) .
Below, we consider p ( z ) :
= N ( 0 , I ) unless otherwise speciﬁed.
A key advantage of using inference networks (also called amortized inference) to train deep generative models over traditional locally stochastic variational inference (Hoffman et al., 2013) is that they share parameters over all data samples, amortizing the computational cost and allowing for efﬁcient training.
The term VAE is often used both to denote the class of generative models and the amortized inference procedure used in training.
In this paper, it is important to distinguish the two and throughout we will refer to the generative model as the VAE-model , and the training procedure as VAE-training .
2. P OSTERIOR C OLLAPSE
Despite VAE’s appeal as a tool to learn unsupervised representations through the use of latent variables, as mentioned VAE-models are often found to ignore latent variable when using a ﬂexible generator like in the introduction LSTMs (Bowman et al., 2016).
This problem of “posterior collapse”, occurs when the training procedure falls into the trivial local optimum of the ELBO objective in which both the variational posterior and true model posterior collapse to the prior.
This is undesirable because an important goal of VAEs is to learn meaningful latent features for inputs.
Mathematically, posterior collapse represents a local optimum of VAEs where q φ ( z | x )
=
p θ ( z | x ) =
p ( z ) for all x .
To facilitate our analysis about the cause leading up to collapse, we further deﬁne two partial collapse states for each x : model collapse , when p θ ( z | x )
= p ( z ) , and inference collapse , when q φ ( z | x ) = p ( z ) .
Note that in this paper we use these two terms to denote the posterior states in the middle of training instead of local optima at the end.
These two partial collapse states may not happen at the same time, which we will discuss later.
2. V ISUALIZATION OF P OSTERIOR D ISTRIBUTION
Posterior collapse is closely related to true model posterior p θ ( z | x ) and approximate posterior q φ ( z | x ) as it is deﬁned.
Thus, in order to observe how posterior collapse happens, we track the state of p θ ( z | x ) and q φ ( z | x ) over the course of training, we will analyze the training trajectory in terms of the posterior mean space U = { µ : µ = ( µ T x , θ , µ T x , φ ) } , where µ x , θ and µ x , φ are the means of p θ ( z | x ) 2 and q φ ( z | x ) , respectively.
We can then roughly consider µ x , θ = 0 as model collapse and µ x , φ = 0 as inference collapse as we deﬁned before.
Each x will be projected to a point in this space under the current model and inference network parameters.
If z is a scalar we can efﬁciently compute µ x , θ and visualize the posterior mean space as shown in Figure 1(b).
The diagonal line µ x , θ = µ x , φ represents parameter settings where q φ ( z | x ) is equal to p θ ( z | x ) in terms of mean, indicating a well-trained inference network.
The posterior collapsed local optimum is located at the origin, 3 while more desirable local optima may be located on the diagonal.
In this paper we will utilize this posterior mean space multiple times to analyze the posterior dynamics.
A L AGGING I NFERENCE N ETWORK P REVENTS U SING L ATENT C ODES
In this section we analyze posterior collapse from a perspective of training dynamics.
We will answer the question of why the basic VAE-training with strong decoders tends to hit a collapsed local optimum and provide intuition for the simple solution we propose in Section 4.
p ✓ ( z | x ) is log p ✓ ( x ) .
However, the dependence (if any) may be lost if q  ( z | x ) is still close to p ( z ) because p ✓ ( z | x ) would be pressured to agree with q  ( z | x )
[This is important, but I think not very clear.
Could you be more explicit?
–GN] .
To examine the dynamic relationship between approximate posterior q  ( z | x ) , model posterior p ✓ ( z | x ) , and prior p ( z ) during basic VAE training, we will next visualize the posterior mean-value space by training a basic VAE with a one-dimensional [“scalar”?
–GN] latent variable on a relatively simple synthetic dataset.
3. O BSERVATIONS ON S YNTHETIC D ATA
As a synthetic dataset we use discrete sequence data, as posterior collapse has been found the most severe in text modeling tasks.
To mimic the diversity of the real data distribution, we sample discrete data from a deep generative model, with a [[[four-mode mixture of Gaussian prior — four-modes of a Gaussian mixture as a prior?]]] and an LSTM generator.
More details about this synthetic dataset and experiment details can be found in Appendix B.1.
We train a basic VAE with a one-dimensional latent variable, LSTM encoder, and LSTM decoderon our synthetic dataset.
We sample 500 data points and show them on the posterior mean space plots at four different training stages from beginning to convergence in Figure 2.
The mean value of the approximate posterior distribution µ x ,  is from the output of the inference network, and µ x , ✓ is approximated by:
[Equation]
where C is a grid set with small stride and sufﬁciently large coverage.
We assume the density value outside this grid set is zero.
p ✓ ( z | x ) is also approximated on this grid.
As illustrated in Figure 2, all points are located at origin [[[after—upon]]] initialization, which means z and x are both almost independent and zero mean at the beginning of training.
In the second stage, the points starts to spread along the µ x , ✓ axis.
This phenomenon implies that for some data points p ✓ ( z | x ) moves far away from the prior p ( z ) , and conﬁrms that log p ✓ ( x ) is able to help escape model collapse.
However, all of these points are still close to the µ x ,  axis, which suggests that q  ( z | x ) fails to catch up to p ✓ ( z | x ) and these points are still in an inference collapsed state.
[Table]
[Figure]
3. I NTUITIONS FROM ELBO
Since posterior collapse is directly relevant to the approximate posterior q φ ( z | x ) and true model posterior p θ ( z | x ) , we aim to analyze their training dynamics to study how posterior collapse happens.
To this end, it is useful to analyze an alternate form of ELBO:
[Equation]
With this view, the only goal of approximate posterior q φ ( z | x ) is to match model posterior p θ ( z | x ) , the optimization of p θ ( z | x ) is inﬂuenced by two forces, one of which is the ideal objective marginal data likelihood, and the other is D KL ( q φ ( z | x ) | p θ ( z | x )) , which drives p θ ( z | x ) to- wards q φ ( z | x ) .
Ideally if the approximate posterior is perfect, the second force will vanish, with ∇ θ D KL ( q φ ( z | x ) | p θ ( z | x ))
= 0 when q φ ( z | x ) =
p θ ( z | x ) .
At the start of training, z and x are nearly independent under both q φ ( z | x ) and p θ ( z | x ) as we show in Section 3.2, i.e. all x suffer from model collapse in the beginning.
Then the only component in the training objective that possibly causes dependence between z and x under p θ ( z | x ) is log p θ ( x ) .
However, this pressure may be overwhelmed by the KL term when p θ ( z | x ) and q φ ( z | x ) starts to diverge.
We hypothesize that, in practice, training drives p θ ( z | x ) and q φ ( z | x ) to the prior in order to bring them into alignment, while locking into model parameters that capture the distribution of x while ignoring z .
Critically, posterior collapse is a local optimum ; once a set of parameters that achieves these goals are reached, gradient optimization fails to make further progress, even if better overall models that make use of z to describe x exist.
Next we visualize the posterior mean space by training a basic VAE with a scalar latent variable on a relatively simple synthetic dataset to examine our hypothesis.
3. O BSERVATIONS ON S YNTHETIC D ATA
As a synthetic dataset we use discrete sequence data, as posterior collapse has been found the most severe in text modeling tasks.
Details on this synthetic dataset and experiment are in Appendix B.1.
We train a basic VAE with a scalar latent variable, LSTM encoder, and LSTM decoder on our synthetic dataset.
We sample 500 data points from validation set and show them on the posterior mean space plots at four different training stages from initialization to convergence in Figure 2.
The mean of the approximate posterior distribution µ x , φ is from the output of the inference network, and µ x , θ can be approximated by discretization of true model posterior p θ ( z | x ) (see Appendix A).
1: θ , φ ← Initialize parameters 2: aggressive ← TRUE 3: repeat 4: if aggressive then 5: repeat (cid:46) [aggressive updates] 6:
X ← Random data minibatch 7:
Compute gradients g
φ ← ∇ φ L ( X ; θ , φ ) 8:
Update φ using gradients g φ 9: until convergence 10:
X ← Random data minibatch 11:
Compute gradients g θ ← ∇ θ L ( X ; θ , φ ) 12:
Update θ using gradients g θ 13: else (cid:46) [basic VAE training] 14:
X ← Random data minibatch 15:
Compute gradients g θ , φ ← ∇ φ , θ L ( X ; θ , φ ) 16:
Update θ , φ using g θ , φ 17: end if 18:
Update aggressive as discussed in Section 4.
19: until convergence
[Figure]
We note that the approximate posterior takes an
As illustrated in Figure 2, all points are located at the origin upon initialization 4 , which means z and x are both almost independent and zero mean at the beginning of training.
In the second stage of basic VAE, the points start to spread along the µ x , θ axis.
This phenomenon implies that for some data points p θ ( z | x ) moves far away from the prior p ( z ) , and conﬁrms that log p θ ( x ) is able to help move away from model collapse.
However, all of these points are still close to the µ x , φ axis, which suggests that q φ ( z | x ) fails to catch up to p θ ( z | x ) and these points are still in a state of inference collapse.
As expected, the dependence between z and x under p
θ ( z | x ) is gradually lost and ﬁnally the model converges to the collapsed local optimum.
M ETHOD 4. A GGRESSIVE T RAINING OF THE I NFERENCE N ETWORK
The problem reﬂected in Figure 2 implies that the inference network is lagging far behind p θ ( z | x ) , and might suggest more “aggressive” inference network updates are needed.
Instead of blaming the poor approximation on the limitation of the inference network’s amortization, we hypothesize that the optimization of the inference and generation networks are imbalanced, and propose to separate the optimization of the two.
Speciﬁcally, we change the training procedure to:
[Equation]
where optimizing the inference network q φ ( z | x ) is an inner loop in the entire training process as shown in Algorithm 1.
This training procedure shares the same spirit with traditional stochastic variational inference (SVI) (Hoffman et al., 2013) that performs iterative inference for each data point separately and suffers from very lengthy iterative estimation.
Compared with recent work that try to combine amortized variational inference and SVI (Hjelm et al., 2016; Krishnan et al., 2018;
Kim et al., 2018; Marino et al., 2018) where the inference network is learned to be a component to help perform instance-speciﬁc variational inference, our approach keeps variational inference fully amortized, allowing for reverting back to efﬁcient basic VAE training as discussed in Section 4.2.
Also, this aggressive inference network optimization algorithm is as simple as basic VAE training without introducing additional SVI steps, yet attains comparable performance to more sophisticated approaches as we will show in Section 6.
4. S TOPPING C RITERION
Always training with Eq.4 would be inefﬁcient and neglects the beneﬁt of the amortized inference network.
Following our previous analysis, the term D KL ( q φ ( z | x ) | p θ ( z | x )) tends to pressure q φ ( z | x ) or p θ ( z | x ) to p ( z ) only if at least one of them is close to p ( z ) , and thus we posit that if we can conﬁrm that we haven’t reached this degenerate condition, we can continue with standard VAE training.
Since q φ ( z | x ) is the one lagging behind, we use the mutual information I q between z and x under q φ ( z | x ) to control our stopping criterion.
In practice, we compute the mutual information on the validation set every epoch, and stop the aggressive updates when I q stops climbing.
In all our experiments in this paper we found that the aggressive algorithm usually reverts back to basic
VAE-training within 5 epochs.
Mutual information, I q can be computed by (Hoffman & Johnson, 2016):
[Equation]
(5) where p d ( x ) is the empirical distribution.
The aggregated posterior, q φ ( z ) =
E x ∼
[Equation] x [Equation] [ q φ ( z | x )] , can be approximated with a Monte Carlo estimate.
D KL ( q φ ( z ) (cid:107) p ( z )) is also approximated by
Monte Carlo, where samples from q φ ( z ) can be easily obtained by ancestral sampling (i.e. sample x from dataset and sample z ∼ q φ ( z | x ) ).
This estimator for I q is the same as in (Dieng et al., 2018), which is biased because the estimation for D KL ( q φ ( z ) (cid:107) p ( z )) is biased.
More speciﬁcally, it is a
Monte Carlo estimate of an upper bound of mutual information.
The complete algorithm is shown in Algorithm 1.
4. O BSERVATIONS ON S YNTHETIC D ATASET
By training the VAE model with our approach on synthetic data, we visualize the 500 data samples in the posterior mean space in Figure 2.
From this, it is evident that the points move towards µ x , θ = µ x , φ and are roughly distributed along the diagonal in the end.
This is in striking contrast to the basic VAE and conﬁrms our hypothesis that the inference and generator optimization can be rebalanced by simply performing more updates of the inference network.
In Figure 3 we show the training trajectory of one single data instance for the ﬁrst several optimization iterations and observe how the aggressive updates help escape inference collapse.
R ELATION TO R ELATED W ORK
Posterior collapse in VAEs is ﬁrst detailed in (Bowman et al., 2016) where they combine a LSTM decoder with VAE for text modeling.
They interpret this problem from a regularization perspective, and propose the “KL cost annealing” method to address this issue, whereby the weight of KL term between approximate posterior and prior increases from a small value to one in a “warm-up” period.
This method has been shown to be unable to deal with collapse on complex text datasets with very large LSTM decoders (Yang et al., 2017;
Kim et al., 2018).
Many works follow this line to lessen the effect of KL term such as β -VAE (Higgins et al., 2017) that treats the KL weight as a hyperparameter or “free bits” method that constrains the minimum value of the KL term.
Our approach differs from these methods in that we do not change ELBO objective during training and in principle maximum likelihood estimation.
While these methods explicitly encourages the use of latent variable, they may implicitly sacriﬁce density estimation performance at the same time, as we will discuss in Section 6.
Another thread of research focuses on a different problem called the “amortization gap” (Cremer et al., 2018) that refers to the difference of ELBO caused by parameter sharing of the inference network.
Some approaches try to combine traditional instance-speciﬁc variational inference with amortized variational inference to narrow this gap (Hjelm et al., 2016; Krishnan et al., 2018;
Kim et al., 2018; Marino et al., 2018).
The most related example is SA-VAE (Kim et al., 2018), which mixes instance-speciﬁc variational inference and empirically avoids posterior collapse.
Our approach is much simpler without sacriﬁcing performance, yet achieves an average of 5x training speedup.
Other attempts to address posterior collapse include proposing new regularizers (Zhao et al., 2017;
Tolstikhin et al., 2018; Phuong et al., 2018), deploying less powerful decoders (Yang et al., 2017;
Semeniuta et al., 2017), using lossy input (Chen et al., 2017), utilizing skip connections (Dieng et al., 2017; 2018), or changing the prior (Tomczak & Welling, 2018; Xu & Durrett, 2018). [Table] [Table]
E XPERIMENTS
Our experiments below are designed to (1) examine whether the proposed method indeed prevents posterior collapse, (2) test its efﬁcacy with respect to maximizing predictive log-likelihood compared to other existing approaches, and (3) test its training efﬁciency.
6. S ETUP
For all experiments we use a Gaussian prior N ( 0 , I ) and the inference network parametrizes a diagonal Gaussian.
We evaluate with approximate negative log likelihood (NLL) as estimated by 500 importance weighted samples 5 (Burda et al., 2016) since it produces a tighter lower bound to marginal data log likelihood than ELBO (ELBO values are included in Appendix C), and should be more accurate.
We also report D KL ( q φ ( z | x ) (cid:107) p ( z ))
(KL), mutual information I q (MI), and number of active units (AU) (Burda et al., 2016) in latent representation.
The activity of a latent dimension z is measured as A z =
Cov x ( E z ∼ q ( z | x ) [ z ]) .
The dimension z is deﬁned as active if A z > 0 .
[Figure] As baselines, we compare with strong neural autoregressive models (LSTM-LM for text and PixelCNN (van den Oord et al., 2016) for images), basic VAE, the “KL cost annealing” method (Bowman et al., 2016; Sønderby et al., 2016), β -VAE (Higgins et al., 2017), and SA-VAE (Kim et al., 2018) which holds the previous state-of-the-art performance on text modeling benchmarks.
For β -VAE we vary β between 0.2, 0.4, 0.6, and 0.8.
SA-VAE is ran with 10 reﬁnement steps.
We also examine the effect of KL cost annealing on both SA-VAE and our approach.
To facilitate our analysis later, we report the results in two categories: “Standard VAE objectives”, and “Modiﬁed VAE objectives”.
We evaluate our method on density estimation for text on the Yahoo and Yelp corpora (Yang et al., 2017) and images on OMNIGLOT (Lake et al., 2015).
Following the same conﬁguration as in
Kim et al.
(2018), we use a single layer LSTM as encoder and decoder for text.
For images, we use a ResNet (He et al., 2016) encoder and a 13-layer Gated PixelCNN (van den Oord et al., 2016) decoder.
We use 32-dimensional z and optimize ELBO objective with SGD for text and
Adam (Kingma & Ba, 2015) for images.
We concatenate z to the input for the decoders.
For text, z also predicts the initial hidden state of the LSTM decoder.
We dynamically binarize images during training and test on ﬁxed binarized test data.
We run all models with 5 different random restarts, and report mean and standard deviation.
Full details for setup are in Appendix B.2 and B.3.
6. R ESULTS
In Table 1 and Table 2 we show the results on all three datasets, we also plot NLL vs AU for every trained model from separate runs in Figure 4 to visualize the uncertainties.
Our method achieves comparable or better performance than previous state-of-the-art systems on all three datasets.
Note that to examine posterior collapse issue for images we use a larger PixelCNN decoder than previous work, thus our approach is not directly comparable to them and included at the top of Table 2 as reference points.
We observe that SA-VAE suffers from posterior collapse on both text datasets without annealing.
However, we demonstrate that our algorithm does not experience posterior collapse without annealing.
6. T IMING
In Table 3 we report the total training time of our approach, SA-VAE and basic VAE-training across the three datasets.
We ﬁnd that the training time for our algorithm is only 2-3 times slower than a regular VAE whilst being 3-7 times faster than SA-VAE
[Table]
[Table]
6. A NALYSIS OF B ASELINES
We analyze the difference between our approach and the methods that weaken the KL regularizer term in ELBO, and explain the unwanted behavior produced by breaking maximum likelihood estimation.
As illustrative examples, we compare with the KL cost annealing method and β -VAE.
Decreasing the weight of the KL regularizer term in ELBO is equivalent to adding an additional regularizer to push q φ ( z | x ) far from p ( z ) .
We set β = 0 .
2 in order to better observe this phenomenon.
We investigate the training procedure on the Yelp dataset based on: (1) the mutual information between z and x , I q , (2) the KL regularizer, E x ∼ p
d ( x ) [ D KL ( q φ ( z | x ) (cid:107) p ( z ))] , and (3) the distance between the aggregated posterior and the prior, D KL ( q φ ( z ) (cid:107) p ( z )) .
Note that the KL regularizer is equal to the sum of the other two as stated in Eq.5.
We plot these values over the course of training in Figure 5.
In the initial training stage we observe that the KL regularizer increases with all three approaches, however, the mutual information, I q , in the annealing remains small, thus a large KL regularizer term does not imply that the latent variable is being used.
Finally the annealing method suffers from posterior collapse.
For β -VAE, the mutual information increases, but D KL ( q φ ( z ) (cid:107) p ( z )) also reaches a very large value.
Intuitively, D KL ( q φ ( z ) (cid:107) p ( z )) should be kept small for learning the generative model well since in the objective the generator p θ ( x | z ) is learned with latent variables sampled from the variational distribution.
If the setting of z that best explains the data has a lower likelihood under the model prior, then the overall model would ﬁt the data poorly.
The same intuition has been discussed in Zhao et al.
(2017) and Tolstikhin et al.
This also explains why β -VAE generalizes poorly when it has large mutual information.
In contrast, our approach is able to obtain high mutual information, and at the same time maintain a small D KL ( q φ ( z ) (cid:107) p ( z )) as a result of optimizing standard ELBO where the KL regularizer upper-bounds D KL ( q φ ( z ) (cid:107) p ( z )) .
6. A NALYSIS OF I NNER L OOP U PDATE
We perform analysis to examine the tradeoff between performance and speed within the inner loop update in our approach, through ﬁxing a budget of updates to the inference network instead of updat- ing until convergence.
In our implementation, we break the inner loop when the ELBO objective stays the same or decreases across 10 iterations.
Note that we do not perform separate learning rate decay in the inner loop so this convergence condition is not strict, but empirically we found it to be sufﬁcient.
Across all datasets, in practice this yields roughly 30 – 100 updates per inner loop update.
Now we explore using a ﬁxed budget of inner loop updates and observe its inﬂuence on performance and speed.
We report the results on Yelp dataset from single runs in Table 4.
We see that sufﬁcient number of inner iterations is necessary to address posterior collapse and achieve good performance, but the performance starts to saturate near convergence, thus we believe that optimizing to a near-convergence point is important.
C ONCLUSION
In this paper we study the “posterior collapse” problem that variational autoencoders experience when the model is parameterized by a strong autoregressive neural network.
In our synthetic experiment we identify that the problem lies with the lagging inference network in the initial stages of training.
To remedy this, we propose a simple yet effective training algorithm that aggressively optimizes the inference network with more updates before reverting back to basic VAE-training.
Experiments on text and image modeling demonstrates the effectiveness of our approach.
A A PPROXIMATION OF THE MEAN OF THE TRUE MODEL POSTERIOR
We approximate the mean of true model posterior p θ ( z | x ) by discretization of the density distribution (Riemann integral):
[Equation]
where C is a partition of an interval with small stride and sufﬁciently large coverage.
We assume the density value outside this interval is zero.
The model posterior, p θ ( z | x ) , needs to be ﬁrst approximated on this partition of interval.
In practice, for the synthetic data we choose the interval [-20.0, 20.0] and stride equal to 0.01.
This interval should have sufﬁcient coverage since we found all samples from true model posterior p θ ( z | x ) lies within [-5.0, 5.0] by performing MH sampling.
B E XPERIMENTAL D ETAILS
In general, for annealing we increase the KL weight linearly from 0.1 to 1.0 in the ﬁrst 10 epochs, as in Kim et al.
We also perform analysis for different annealing strategies in Appendix E
B.
S YNTHETIC EXPERIMENT FOR S ECTION 3 AND
To generate synthetic data points, we ﬁrst sample a two-dimensional latent variable z from a mixture of Gaussian distributions that have four mixture components.
We choose dimension two because we want the synthetic data distribution to be relatively simple but also complex enough for a onedimensional latent variable model to ﬁt.
We choose mixture of Gaussian as the prior to make sure that the synthetic data is diverse.
The mean of these Gaussians are (-2.0, -2.0), (-2.0, 2.0), (2.0, -2.0), (2.0, 2.0), respectively.
All of them have a unit variance.
Then we follow the synthetic data generation in Kim et al.
(2018), where we sample data points from an one-layer LSTM conditioned on latent variables.
The LSTM has 100 hidden units and 100-dimensional input embeddings.
An afﬁne transformation of z is used as the initial hidden state of LSTM decoder, z is also concatenated with output of LSTM at each time stamp to be directly mapped to vocabulary space.
LSTM parameters are initialized with U ( − 1 , 1) , and the part of MLP that maps z to vocabulary space is initialized with
U ( − 5 , 5) , this is done to make sure that the latent variables have more inﬂuence in generating data.
We generated a dataset with 20,000 examples (train/val/test is 16000/2000/2000) each of lengthfrom a vocabulary of size 1000.
In the synthetic experiment we use a LSTM encoder and LSTM decoder, both of which havehidden units and 50 latent embeddings.
This LSTM decoder has less capacity than the one used for creating the dataset since in real world model capacity is usually insufﬁcient to exactly model the empirical distribution.
Parameters of LSTM decoders are initialized with U ( − 0 .
01 , 0 . 01) , except the embedding weight matrix which is initialized with U ( − 0 .
Dropout layers with probability 0.5 are applied to both input embeddings and output hidden embeddings of decoder.
We use SGD optimizer and start with a learning rate of 1.0 and decay it by a factor of 2 if the validation loss has not improved in 2 epochs and terminate training once the learning rate has decayed a total of 5 times.
B. T EXT
Following (Kim et al., 2018), we use a single-layer LSTM with 1024 hidden units and 512dimensional word embeddings as the encoder and decoder for all of text models.
The LSTM parameters are initialized from U ( − 0 .
01 , 0 . 01) , and embedding parameters are initialized from
U ( − 0 .
We use the ﬁnal hidden state of the encoder to predict (via a linear transformation) the latent variable.
We use SGD optimizer and start with a learning rate of 1.0 and decay it by a factor of 2 if the validation loss has not improved in 2 epochs and terminate training once the learning rate has decayed a total of 5 times.
We don’t perform any text preprocessing and use the datasets as provided.
We follow Kim et al.
and use dropout of 0.5 on the decoder for both the input embeddings of the decoder and on the output of the decoder before the linear transformation to vocabulary space.
B. I MAGES
We use the same train/val/test splits as provided by Kim et al.
We use Adam optimizer and start with a learning rate of 0.001 and decay it by a factor of 2 if the validation loss has not improved in 20 epochs and terminate training once the learning rate has decayed a total of 5 times.
Inputs were dynamically binarized throughout training by viewing the input as Bernoulli random variables that are sampled from pixel values.
We validate and test on a ﬁxed binarization and our decoder uses binary likelihood.
Our ResNet is the same as used by Chen et al.
Our 13-layer PixelCNN architecture is a larger variant based on what was used in Kim et al.
and described in their
Appendix B.3 section.
The PixelCNN has ﬁve 7 x 7 layers, followed by, four 5 x 5 layers
[Table]
and then four 3 x 3 layers.
Each layer has 64 feature maps.
We use batch normalization followed by an ELU activation before our ﬁnal 1 x 1 convolutional layer and sigmoid nonlinearity
[Table]
C A DDITIONAL R ESULTS C ONTAINING ELBO
[Table]
[Table]
D U NCERTAINTY OF E VALUATION
To measure the uncertainty in the evaluation stage caused by random Monte Carlo samples, we load a pre-trained VAE model trained by our approach and basic VAE training, and repeat our evaluation process with 10 different random seeds.
We report the mean and variance values in Table 7 and
Table 8.
[Table] [Table]
E C OMPARISON WITH DIFFERENT KL- ANNEALING SCHEDULES
For the annealing baseline in Table 1 and Table
[Table]
we implement annealing as increasing KL weight linearly from 0.1 to 1.0 in the ﬁrst 10 epochs following (Kim et al., 2018) [Table] and observed posterior collapse for KL-annealing method.
However, this annealing strategy may not be the optimal.
In this section, we explore different KL-annealing schedules.
Speciﬁcally, we increase KL weight linearly from 0.0 to 1.0 in the ﬁrst s iterations, and s is varied as 30k, 50k, 100k, and 120k.
We report results on three datasets in Table 9.
The results indicate that KL-annealing does not experience posterior collapse if the annealing procedure is sufﬁciently slow, but it does not produce superior predictive log likelihood to our approach, which is expected because a very slow annealing schedule resembles β -VAE training in the ﬁrst many epochs, and β -VAE encourages learning latent representations but might sacriﬁce generative modeling performance, as we already showed in Table 1 and Table 2.
Also, the optimal KL annealing schedule varies with different datasets and model architectures, so that it requires careful tuning for the task at hand.
[Table]
F S EPARATE L EARNING R ATES OF I NFERENCE N ETWORK AND G ENERATOR
The lagging behavior of inference networks observed in Section 3 might be caused by different magnitude of gradients of encoder and decoder 9 , thus another simpler possible solution to this problem is to use separate learning rates for the encoder and decoder optimization.
Here we report the results of our trial by using separate learning rates.
We experiment with Yelp dataset, and keep the decoder optimization the same as discussed before, but varying the encoder learning rates as 1x, 2x, 4x, 6x, 8x, 10x, 30x, 50x of the decoder learning rates.
We notice that training becomes very unstable when encoder learning rate is too large, particularly it experiences KL value explosion for all the 8x, 10x, 30x, 30x, 50x settings.
Therefore, in Table 10 we only report the settings where we obtained meaningful results.
All of the settings suffer from posterior collapse, which means simply changing learning rates of encoders may not be sufﬁcient to circumvent posterior collapse.
[Table]
G D ISCUSSION ABOUT I NITIALIZATION OF I NFERENCE N ETWORKS
In Section 3 we observe and analyze the lagging behavior of inference networks on synthetic data, but Figure 2 only shows the setting where the model is initialized at the origin.
It remains unknown if a different initialization of inference networks would also suffer from posterior collapse, and whether our approach would work in that case or not.
Here we explore this setting.
Speciﬁcally, we add an offset to the uniform initialization we used before: we initialize all parameters as
U (0 . 04 , 0 . 06) (previously U ( − 0 .
01 , 0 . 01) ), except the embedding weight as U (0 . 0 , 0 . 2) (previously
U ( − 0 .
Since all parameters are positive values the output of encoder must be positive.
We show the posterior mean space over course of training in Figure 6.
Note that all points are located at (approximately) the same place, and are on µ x , θ = 0 upon initialization, which means z and x are still nearly independent in terms of both p θ ( x | z ) and q φ ( z | x ) .
We observe that in basic VAE training these points move back to µ x , φ = 0 very quickly.
This suggests that the “lagging” issue might be severe only at the inference collapse state.
In such setting our approach works similarly as before.
[Table]
6x, 8x, 10x, 30x, 50x of the decoder learning rates.
We notice that training becomes very unstable when encoder learning rate is too large, particularly it experiences KL value explosion for all the 8x, 10x, 30x, 30x, 50x settings.
Therefore, in Table 11 we only report the settings where we obtained meaningful results.
All of the settings suffer from posterior collapse, which means simply changing learning rates of encoders may not be sufﬁcient to circumvent posterior collapse.
[Table]
G D ISCUSSION ABOUT I NITIALIZATION OF E NCODERS
[Table]
[Table]
+jhU2r4I8IT935ESafI1rTJPZq6WM6CUMFWrgqHMUz5m8jdjGVQDWc1F2oRmYREIL7spj+IEWESne4SJwKBwbhjuc80oiLEFhGpuT8F0SDShYG0tWo/qi44sA++sdlVz784rjeuZWQVURsfoFNXRBWqgW9REHqLoGb2iN/TuvDgfzqfzNZWuOLOeIzQXzs8fgA2lpg==</latexit>