Year: 2021

Abstract:
Stochastic Variational Inference is a powerful framework for learning large-scale probabilistic latent variable models. However, typical assumptions on the factorization or independence of the latent variables can substantially restrict its capacity for inference and generative modeling. A major line of active research aims at building more expressive variational models by designing deep hierarchies of interdependent latent variables. Although these models exhibit superior performance and enable richer latent representations, we show that they incur diminishing returns: adding more stochastic layers to an already very deep model yields small predictive improvement while substantially increasing the inference and training time. Moreover, the architecture for this class of models favors proximate interactions among the latent variables between neighboring layers when designing the conditioning factors of the involved distributions. This is the first work that proposes attention mechanisms to build more expressive variational distributions in deep probabilistic models by explicitly modeling both nearby and distant interactions in the latent space. Specifically, we propose deep attentive variational autoencoder and test it on a variety of established datasets. We show it achieves state-of-the-art log-likelihoods while using fewer latent layers and requiring less training time than existing models. The proposed holistic inference reduces computational footprint by alleviating the need for deep hierarchies.

heading: 1 INTRODUCTION
text: A core line of research in both supervised and unsupervised learning relies on deep probabilistic models. This class of models uses deep neural networks to model distributions that express hypotheses about the way in which the data have been generated. Such architectures are preferred due to their capacity to express complex, non-linear relationships between the random variables of interest while enabling tractable inference and sampling. Latent variable probabilistic models augment the set of the observed variables with auxiliary latent variables. They are characterized by a posterior distribution over the latent variables, one which is generally intractable and typically approximated by closed-form alternatives. They provide an explicit parametric specification of the joint distributions over the expanded random variable space, while the distribution of the observed variables is computed by marginalizing over the latent variables. The Variational Autoencoder (VAE) (Kingma & Welling, 2014) belongs to this model category. The VAE uses neural networks for learning the parametrization of both the inference network (which defines the posterior distribution of the latent variables) and the generative network (which defines the prior distribution of the latent variables and the conditional data distribution given the latent variables). Their parameters are jointly learned via stochastic variational inference (Paisley et al., 2012; Hoffman et al., 2013).
Early VAE architectures (Rezende et al., 2014) make strong assumptions about the posterior distribution—specifically, it is standard to assume that the posterior is approximately factorial. Since then, research has progressed on learning more expressive latent variable models. For example, Rezende & Mohamed (2015); Kingma et al. (2016); Chen et al. (2017) aim at modeling more complex posterior distributions, constructed with autoregressive layers. Theoretical research focuses on deriving tighter bounds (Burda et al., 2016; Li & Turner, 2016; Masrani et al., 2019) or building more informative latent variables by mitigating posterior collapse (Razavi et al., 2019a; Lucas et al., 2019). Sinha & Dieng (2021) improve generalization by enforcing regularization in the latent space for semantics-preserving transformations of the data. Taking a different approach, hierarchical VAEs (Gulrajani et al., 2017; Sønderby et al., 2016; Maaløe et al., 2019; Vahdat & Kautz, 2020; Child,
2020) leverage increasingly deep and interdependent layers of latent variables, similar to how subsequent layers in a discriminative network are believed to learn increasingly abstract representations of the data. These architectures exhibit superior generative and reconstructive capabilities since they allow for modeling of much richer structures in the latent space.
Previous work overlooks the effect of long-range correlations among the latent variables. In this work, we propose to restructure common hierarchical, convolutional VAE architectures in order to increase the receptive field of the variational distributions. We first provide experimental evidence that conditional dependencies in deep probabilistic hierarchies may be implicitly disregarded by current models. Subsequently, we propose a decomposed, attention-guided scheme that allows a long-range flow of both the latent and the observed information both across different, potentially far apart, stochastic layers and within the same layer and we investigate the importance of each proposed change through extensive ablation studies. Finally, we demonstrate that our model is both computationally more economical and can attain state-of-the-art performance across a diverse set of benchmark datasets.

heading: 2 PROPOSED MODEL

heading: 2.1 DEEP VARIATIONAL INFERENCE
text: A latent variable generative model defines the joint distribution of a set of observed variables, x ∈ RD, and auxiliary latent variables, z, coming from a prior distribution p(z). To perform inference, the marginal likelihood of the distribution of interest, p(x), can be computed by integrating out the latent variables:
p(x) = ∫ p(x, z) dz. (1)
Since this integration is generally intractable, a lower bound on the marginal likelihood is maximized instead. This is done by introducing an approximate posterior distribution q(z | x) and applying Jensen’s inequality:
log p(x) = log ∫ p(x, z) dz = log ∫ q(z | x) q(z | x) p(x, z) dz ≥ ∫ q(z | x) log [ p(x | z)p(z) q(z | x) ] dz
=⇒ log p(x) ≥ Eq(z|x)[log p(x | z)]−DKL(q(z | x) ∥ p(z)), (2)
where θ, ϕ parameterize p(x, z;θ) and q(z | x;ϕ) respectively. For ease of notation, we omit θ,ϕ in the derivations. This objective is called the Evidence Lower BOund (ELBO) and can be optimized efficiently for continuous z via stochastic gradient descent (Kingma & Welling, 2014; Rezende et al., 2014).
For ease of implementation, it is common to assume that both q(z | z) and p(z) are fully factorized Gaussian distributions. However, this assumption may be too limiting in cases of complex underlying distributions. To compensate for this modeling constraint, many works focus on stacking and improving the stability of multiple layers of stochastic latent features which are partitioned in groups such that z = {z1, z2, . . . ,zL}, where L is the number of such groups (Rezende et al., 2014; Gulrajani et al., 2017; Kingma et al., 2016; Sønderby et al., 2016; Maaløe et al., 2019; Vahdat & Kautz, 2020; Child, 2020). Our work builds on architectures of bidirectional inference with a deterministic bottom-up pass. The schematic diagram of a stochastic layer in such a deep variational model is depicted in Figure 1. In a bidirectional inference architecture with a deterministic bottom-up pass (left part in Figure 1a), posterior sampling is preceded by a sequence of non-linear transformations, T ql , of the evidence, x, i.e., hl = T q l (hl+1), with hL+1 = x. The inference q(z | x) and generative
p(z) network decompose in an identical topological ordering: q(z | x) = ∏
l q(zl | x, z<l) and p(z) = ∏ l p(zl | z<l). The top-down pass (right part in Figure 1a) generates the posterior samples z that feed the conditional data distribution p(x | z).

heading: 2.2 MOTIVATION
text: Kingma et al. (2016) proposed a strongly connected directed probabilistic graphical model for the generative and inference network, so that each variable depends on all the previous in the hierarchy:
p(zl | z<l). Similarly, for the inference model: q(zl | x, z<l). This is in contrast to other works (Sønderby et al., 2016) that consider statistical dependencies between successive layers only, i.e., p(zl | zl−1). Maaløe et al. (2019) also highlight the importance of this modification. The longrange conditional dependencies are implicitly enforced via deterministic features that are mixed with the latent variables and propagated through the hierarchy (see feature cpl in Figure 1a).
State-of-the-art models (Vahdat & Kautz, 2020; Child, 2020) leverage this fully-connected factorization and rely on the increased depth to improve performance and deliver results comparable to that of autoregressive models (Salimans et al., 2017). However, by construction, very deep VAE architectures favor only proximate dependencies in the latent space, limiting longrange conditional dependencies between zl and z<l−1 as depth increases. This means that in practice the network may no longer respect the factorization of the variational distributions p(z) =∏
l p(zl | z<l) and q(z | x) = ∏
l q(zl | x, z<l), leading to sub-optimal performance. Table 1 reports the absolute and relative decrease in the negative log-likelihood (in bits per dimension) as one increases the number of stochastic layers in an NVAE (Vahdat & Kautz, 2020). We observe that the predictive gains diminish as depth increases. We hypothesize that this may be because the effect of the latent variables of earlier layers diminishes as the context feature cpl traverses the hierarchy and is updated with latent information from subsequent layers.
In this work, we improve the flexibility of the prior p(z) and posterior q(z | x) by designing more informative conditioning factors of the conditional distributions p(zl | z<l) and q(zl | x, z<l). We do this by designing a hierarchy of densely connected stochastic layers that learn to attend to latent and observed information most critical for inference. Figure 1b is a graphical illustration of the proposed model.
2.3 DEPTH-WISE ATTENTION
Figure 2: Attend(c<l, sl, k<l)− a depth-wise attention block. c<l, k<l are the sequences of l − 1 contexts and corresponding keys with C and Q feature maps accordingly, while sl is the query feature. The multiplication is applied to the inner matrix dimensions. The normalization of the softmax is applied to the last dimension, treating each pixel independently from the others. α<l = {αm→l}l−1m=1 are the attention scores.
We first introduce depth-wise attention. This is the technical tool that allows our model to realize the strong couplings presented in Figure 1b and motivated in Section 2.2. The problem can be formulated as follows:
Given a sequence c<l = {cm}l−1m=1 of l − 1 contexts, we need to construct a feature ĉl that summarizes the information in c<l that is most critical for a given task. ĉl and cm are features of the same dimensionality: ĉl ∈ RH×W×C , and cm ∈ RH×W×C . In our framework, this task is the construction of either prior (Section 2.4) or posterior (Section 2.5) beliefs of a variational layer in a deep VAE. Therefore, our architecture must be need to handle long context sequences of large dimensions H and W .
The task is characterized by a query feature sl ∈ RH×W×Q of dimensionality Q with Q≪ C. Similarly, cm is represented by a key feature km ∈ RH×W×Q. To reduce computational requirements, we treat each pixel independently from the rest. This can equivalently be interpreted as concurrent processing of H ×W independent sequences of C-dimensional features. The feature maps ĉl(i, j) ∈ RC for pixels (i, j), with 1 ≤ i ≤ H , 1 ≤ j ≤W , are computed in parallel. ĉl(i, j) depends only on pixel instances in c<l at the same location (i, j), i.e, cm(i, j) with m < l, and is given by:
ĉl(i, j) = ∑ m<l αm→l(i, j)cm(i, j), (3)
αm→l(i, j) = exp(sTl (i, j)km(i, j))∑
m<l exp(s T l (i, j)km(i, j))
. (4)
In words, feature sl(i, j) ∈ RQ queries the significance of feature cm(i, j) ∈ RC , represented by km(i, j) ∈ RQ, to form ĉl(i, j) ∈ RC . αm→l(i, j) ∈ R, is the resulting relevance metric of the m−th term, with m < l, at pixel (i, j). The overall procedure is denoted as ĉ = Attend(c<l, sl, k<l), and is illustrated in Figure 2.
Finally, to improve training of models with very long sequences, we adopt the following variant of the normalization scheme proposed by Chen et al. (2020):
c<l ← c<l +Gelu(LayerNorm(c<l)), (5) ĉl ← ĉl +Gelu(LayerNorm(ĉl)), (6)
where Gelu is the GELU non-linearity (Hendrycks & Gimpel, 2016) and LayerNorm a layer normalization operation (Ba et al., 2016).

heading: 2.4 GENERATIVE MODEL
text: As shown in Figure 1a, the conditioning factor of the prior distribution at variational layer l is a context feature cpl ∈ RH×W×C . A convolution is applied on c p l to obtain parameters θ defining
the prior. cpl is a non-linear transformation of the immediately previous latent information zl−1 and prior context c<l−1 containing latent information from distant layers z<l−1, such that c p l = T pl (zl−1 ⊕ c p l−1). T p l (·) is typically implemented as a cascade of ResNet cells (He et al., 2016a;b) and corresponds to the blue ResNet module in Figure 1a. The operator ⊕ combines information from two branches in the network (e.g. by summation or concatenation). zl−1, c p l−1 are passed in from the previous layer.
Due to the locality of the architecture, the signal from cpl may be dominated by that of zl−1. To prevent this, we adopt direct connections between each pair of stochastic layers, as shown in Figure 1b. That is, variational layer l has direct access to prior context of all previous layers cp<l accompanied by keys kp<l. This means each variational layer can actively determine the most important latent contexts when evaluating its prior beliefs. During training, the context, query, and key are jointly learned:
[cpl , s p l , k p l ]← T p l (zl−1 ⊕ c p l−1). (7)
We initially let variational layer l rely on nearby dependencies, captured by cpl . During training, the prior is progressively updated with the holistic context ĉpl via a residual connection (Wang et al., 2018; Bachlechner et al., 2021):
ĉpl ← Attend(c p <l, s p l , k p <l), (8) ĉpl ← c p l + γ p l ĉ p l , (9)
where γpl ∈ R is a learnable scalar parameter initialized to zero, c p <l = {cpm} l−1 m=1 with c p m ∈ RH×W×C , spl ∈ RH×W×Q, k p <l = {kpm} l−1 m=1 with k p m ∈ RH×W×Q, and Q≪ C.

heading: 2.5 INFERENCE MODEL
text: As shown in Figure 1a, the condition cql of the posterior distribution results from combining deterministic factor hl and stochastic factor c p l provided by the decoder: c q l = hl ⊕ c p l . To improve inference, we let layer’s l encoder use both its own hl and all subsequent hidden representations h>l, as shown in Figure 1b. This modification can also be viewed as skip connections which selectively connect each layer with representations closer to the data helping deep signal propagation. As in the generative model, the bottom-up path is extended to emit low dimensional key features kql which represent hidden features hl:
[hl, k q l ]← T q l (hl+1 ⊕ k q l+1). (10)
Prior works (Sønderby et al., 2016; Vahdat & Kautz, 2020) have sought to mitigate against exploding DKL in Equation 2 by using parametric coordination between the prior and posterior distributions. Motivated by this insight, we seek to establish further communication between them. We accomplish this by allowing the generative model to choose the most explanatory features in h≥l by generating query feature sql . Finally, the holistic conditioning factor for the posterior is:
ĉql ← Attend(h≥l, s q l , k q ≥l). (11)
The detailed description is deferred to Appendix A.1. Inference on the model is also summarized in Appendix A.3.

heading: 2.6 SPATIALLY ATTENTIVE VARIATIONAL LAYERS
text: In Sections 2.4 and 2.5, we allowed the perceptive field of each pixel at layer l to encompass only pixels at the same locations in earlier layers during inference. In order to fully capture distant dependencies in the latent space, we still need to coordinate portions of information in the spatial domain. To increase the computational efficiency of our model, this occurs at a second stage. Conceptually, this two-step procedure resembles the factorized attention of efficient transformers (Child et al., 2019), albeit deep variational models are inherently amenable to a different, inter-layer and intralayer, decomposition. This observation decreases the time and memory complexity of the long-range operations for computing the attention scores from O(L3 ×W 2 ×H2) to O(L2 +L×W 2 ×H2), while still providing inference with holistic information. To accomplish this, we interleave spatially non-local blocks (Wang et al., 2018) with the convolutions in the residual cells of the ResNet modules in Figure 1, as shown in Figure 3 in Appendix. The exact formulation is similar to that of Wang et al. (2018) and is provided in Appendix A.2.

heading: 3 EXPERIMENTAL STUDIES
text: We conduct three series of experiments. In the first set of experiments (Section 3.1.1), we apply the attentive variational path proposed in this paper on VAEs that are trained on two datasets of binary images: the dynamically binarized MNIST and OMNIGLOT. In Section 3.1.2, we investigate the effectiveness of the proposed techniques on large-scale latent spaces that are used for generating the CIFAR-10 natural images. Qualitative results are provided in Appendices D (plot of KL divergence per layer), E (visualization of attention patterns), and F (novel samples and image reconstructions). Finally, in Section 3.2 we conduct an ablation study and report the benefits of each proposed attention module separately. All hyperparameters for experiments are available in Appendix B. We note here that we choose to not use spectral regularization, and we find this does not compromise training stability of our model (in contrast to results reported by Vahdat & Kautz (2020)). The fact that our model is able to achieve better performance without this regularization may indicate that the attention operations help stabilize training.

heading: 3.1 MAIN QUANTITATIVE RESULTS

heading: 3.1.1 APPLICATION ON BINARY IMAGES
text: Datasets. We evaluate the models on two benchmark datasets: MNIST (LeCun et al., 1998), a dataset of 28 × 28 images of handwritten digits, and OMNIGLOT (Lake et al., 2013), an alphabet recognition dataset of 28 × 28 images. For convenience, we add two zero pixels to each border of the training images. In both cases, the observations are dynamically binarized by being resampled from the normalized real values using a Bernoulli distribution after each epoch, as suggested by Burda et al. (2016), which prevents over-fitting. We use the standard splits of MNIST into 60,000 training and 10,000 test examples, and of OMNIGLOT into 24,345 training and 8,070 test examples.
Set-up. For both datasets, we use a hierarchy of L = 15 variational layers. We use a Bernoulli distribution in the image decoder. In the generative model a non-local block is inserted at the end of the module responsible for combining the context with the latent sample provided by the previous layer. In the inference layer, a non-local block is inserted at the end of the module responsible for concatenating the deterministic, data-dependent features of the bottom-up pass and the context containing latent information that is provided by the generative model. Non-local blocks are also inserted at the post-processing cells, at the end of the variational hierarchy and right before the layers that implement the data distribution (see Appendix B for details). MNIST images are downsampled twice before being passed to the hierarchy leading to latent spaces of spatial dimension 8× 8 while the OMNIGLOT images are downsampled only once resulting to 16× 16 latent spaces. Results. Table 10 reports the estimated marginal likelihood of our model along with the performance achieved by state-of-the-art models. We observe that in both datasets, holistic variational inference consistently improves performance. More importantly, our model outperforms models that increase the flexibility of the variational posterior by making use of normalizing flows (Kingma et al., 2016) or the data distribution by making use of autoregressive decoders (Chen et al., 2017). The use of autoregressive layers is a model refinement orthogonal to ours and it could potentially further improve the results presented in Table 10. The architecture closest to ours is NVAE (Vahdat & Kautz, 2020), and the performance gap can be solely attributed to long-range inference operations described in Sections 2.4, 2.5, and 2.6.

heading: 3.1.2 APPLICATION ON NATURAL IMAGES
text: Dataset. CIFAR-10 is a dataset of 32 × 32 natural images. The raw pixel values are first scaled to [−1, 1]. Set-up. For CIFAR-10, we use a hierarchy of L = 16 variational layers. We use a mixture of discretized Logistic distributions (Salimans et al., 2017) for the data distribution. We use the spatially non-local residual cells of Figure 3 in both the generative and inference network of each layer. Nonlocal blocks are also inserted at the pre-processing blocks, at the beginning of the bottom-up pass (see Appendix B for details). CIFAR-10 images are downsampled only once resulting to 16 × 16 latent spaces. We note that it helps optimization if we bound the log of the prior standard deviation such that log σp ≥ −1.0, yielding less confident prior assumptions. We also empirically find that
adding Gaussian noise with σnoise = 0.001 in both the log of the prior scale log σp and the posterior scale log σq helps network’s generalization.
Results. Table 3 shows the performance of the proposed model both among other VAEs and other purely generative models. As we can see, attention-guided variational inference is conducive to building more informative latent spaces, rendering the model the best performing in its class. This claim is further corroborated by qualitative results in Appendix D. We can see there that the attention-driven skip connections mitigate posterior collapse by activating early layers in the hierarchy. Moreover, our model closes the performance gap between VAEs and expensive generative models that rely on fully-autoregressive distributions. Finally, it is possible our results in Table 3 could be improved by considering deeper hierarchies.
In Table 4, we compare the computing demands for training our model with the one of the other two most competitive VAEs presented in Table 3. As we see, our 16-layer VAE requires almost 3/5 of the GPU hours needed for training a 30-layer NVAE, while still outperforming the more efficient VAE of Child (2020). In this work, we implement full rank matrices for the self-attention scores of the spatially non-local residual cells. Efficient attention approximations such as those proposed by Child et al. (2019) and Choromanski et al. (2021) could further reduce the computational requirements of our models and are left as future work. This suggestion is also bolstered by our findings in Appendix E, where we observe that the spatial attention maps are sparse and highly structured.

heading: 3.2 ABLATION STUDY
text: To verify the effectiveness on the performance of the different attention schemes proposed in Section 2, we conduct comprehensive ablation studies on architectures of a variable number of stochastic layers on the CIFAR-10 dataset. We incrementally add different combinations of the proposed attention components of Sections 2.4, 2.5, 2.6 in the NVAE architecture and we evaluate their impact on the estimated marginal likelihood reported in bits per dimension. Our results are shown in Table 5. We make the following observations:
• Regardless of the number of stochastic layers in the hierarchy, we observe improvement over the baseline model (Case 1 vs Case 8 and Case 9 vs Case 16 in Table 5).
• We notice that the 8-layer architecture that employs an attention mechanism in both the generative network and the inference counterpart of the model (Case 8 in Table 5) almost reaches the performance level of the baseline 16-layer architecture (Case 9 in Table 5). This fact indicates that our model results in a better utilization of the latent space. This is orthogonal to other works which aim at improvement by stabilizing deeper architectures instead.
• The effect of the spatially attentive stochastic layers is larger in the shallower architecture (Case 1 vs Case 2 and Case 9 vs Case 10 in Table 5). This may be because some loss of the latent information is compensated by additional layers. However, the total improvement yielded by the depth-wise attention modules is larger in the deeper architecture, highlighting the importance of the inter-layer connectivity when constructing the prior and the posterior of each layer. The inter-layer connectivity is also visualized in Figures 6, 7 in Appendix E, where it is confirmed that the model learns to attend to context information that lies in distant layers of the model to improve performance.
Finally, supplementary ablations on other architectural choices of our model are provided in Appendix C.

heading: 4 RELATED WORK AND DISCUSSION
text: Our work builds on recent deep variational autoencoders (Vahdat & Kautz, 2020; Child, 2020), which first perform a fully deterministic bottom-up pass followed by a top-down pass involving both stochastic and deterministic features, as first proposed by Kingma et al. (2016). This hybrid top-down pass enables fully connected factorizations of the joint prior and posterior distributions, according to which the latent variables of each layer are conditioned on the latent variables of all the layers above in the hierarchy. However, modeling such conditional dependencies relies on local architectures which assume connectivity only between successive layers. We improve on prior work by introducing attention-guided mechanisms to actively discover long-range statistical dependencies in the latent space. We build on top of NVAE (Vahdat & Kautz, 2020) to demonstrate our method, but our suggestions are generic and could be applied to deeper and thinner hierarchies such as that of Child (2020), or the BIVA hierarchy which extends the deterministic bottom-up pass to latent variables (Maaløe et al., 2019). These configurations could further improve the results reported in Tables 10, 3. Moreover, the proposed model is amenable to other tools for improved variational inference such as the use of an autoregressive posterior (or prior) distribution (Kingma et al., 2016), a second-stage ancenstral sampling by an auxiliary VAE that learns the aggregated posterior (Dai & Wipf, 2019), or regularization techniques that promote congruence between latent representations of the original and transformed inputs (Sinha & Dieng, 2021).
Vector Quantized Variational Autoencoders (VQ-VAEs), first proposed by Razavi et al. (2019b), learn discrete latent representations. However, the training objective of these models does not formally constitute a lower bound on the marginal log-likelihood. Although VQ-VAEs have exhibited high-quality generative capability on high-resolution images, they base their performance on fully autoregressive PixelCNN priors (Van Den Oord et al., 2016) which render them too slow to sample from in case of large latent spaces. Most related to ours is the work of Esser et al. (2021). The authors use a fully autoregressive transformer in the latent space. However, they manage to handle low-dimensional latent spaces, leading to log-likelihoods infererior to that of Razavi et al. (2019b). Scaling this model to larger latent spaces, by leveraging the decomposed, attention-guided latent hierarchy proposed in this work could be an interesting future research direction.
Several works on generative modeling leverage self-attention mechanisms (Parmar et al., 2018; Chen et al., 2018; 2020; Child et al., 2019). However, these models are autoregressive, yielding conditional per-pixel distributions, and apply attention in the pixel space. Therefore, as already discussed, they are slow to sample from. Our work has log-likelihood performance comparable to that of these works, while using a non-autoregressive data distribution. The work of Tulsiani & Gupta (2021) uses a transformer-based encoder to learn pixel distributions conditioned on a small set of observed pixel values at arbitrary locations. Diffusion models (Ho et al., 2019; Kingma et al., 2021) can be viewed as VAEs and achieve impressive generative quality. However, similarly to the autoregressive models, sampling from them requires multiple network evaluations. Morever, their performance when trained with data augmentation (Kingma et al., 2021) can be similar to that of deep regularized VAEs (Sinha & Dieng, 2021). Finally, the work by Zhang et al. (2019) boosts GANs by incorporating non-local blocks (Wang et al., 2018) in the generator and the discriminator.
Future research includes investigating the effect of the proposed depth-wise attention mechanism on ResNet architectures for different tasks and efficient attention approximations specific to deep variational inference.

heading: 5 CONCLUSION
text: We have presented deep attentive VAE, the first attention-driven framework for variational inference in deep probabilistic models. We argue that the expressivity of current deep probabilistic models can be improved by selectively prioritizing statistical dependencies between latent variables that are potentially distant from each other. We introduced a scalable factorized attention scheme that first discovers intra-layer correlations, succeeded by inter-layer attention operations. Moreover, the generative model is allowed to query its posterior counterpart based on the available latent information to identify the data-dependent representations most informative for inference. We extensively evaluated the proposed architecture on multiple public datasets and showed that our model outperforms all existing deep VAEs, while requiring significantly less training time.

heading: A MODEL ARCHITECTURE
text: A.1 INFERENCE NETWORK
In this section, we provide the formal description of the attention-enhanced inference network presented in Section 2.5. Equivalently, we will present the procedure for the construction of the conditioning factor of the posterior distribution q(zl | x, z<l). The inference network is first traversed from the bottom (stochastic layer closer to the data x) to the top, to compute successive hidden data representations hl ∈ RH×W×C and their keys: kql ∈ RH×W×Q, with Q≪ C:
[hl, k q l ]← T q l (hl+1 ⊕ k q l+1), for l = L,L− 1, . . . , 1. (12)
L is the number of stochastic layers. We assume hL+1 ≡ x. T ql is a non-linear transformation, typically implemented as a cascade of ResNet cells (He et al., 2016a;b).
Afterwards, samples from the posterior are drawn in top-down order in the topological ordering of the generative model:
z1 ∼ q(z1 | x), zl ∼ q(zl | x, z<l), for l = 2, . . . , L. (13)
The inference network receives the prior context cpl ∈ RH×W×C and a query feature s q l ∈ RH×W×Q from the generative model, see Equation 7. cpl and s q l contain latent information of previous layers z<l. The observed, data-dependent feature hl and the latent feature c p l are combined via an operator ⊕ to give the context of the posterior cql ∈ RH×W×C along with its key kp,ql ∈ RH×W×Q:
[cql , k p,q l ]← hl ⊕ c p l . (14)
As already pointed out, kp,ql contains stochastic, latent information, while k q l of Equation 12 contains only deterministic, observed information.
We allow variational layer l to have access to hl and all subsequent data representations h>l. During inference, the variational layer decides parts of the deterministic features h≥l and the stochastic feature cql to pay attention to. For pixel (i, j), with 1 ≤ i ≤ H , 1 ≤ j ≤ W , the generative model queries according to sql (i, j) ∈ RQ and computes an attention distribution, as follows:
αqm→l(i, j) = exp(kqm(i, j) Tsql (i, j))
Zq(i, j) , (15)
αqp→l(i, j) = exp(kp,ql (i, j) Tsql (i, j))
Zq(i, j) , (16)
Zq(i, j) = exp(kp,ql (i, j) Tsql (i, j)) + ∑ m≥l exp(kqm(i, j) Tsql (i, j)). (17)
αqp→l(i, j) ∈ R reflects the importance of stochastic context c q l (i, j) ∈ RC to pixel (i, j). Similarly, αqm→l(i, j) ∈ R reflects the importance of deterministic feature hm(i, j) ∈ RC of layer m to pixel (i, j). Zq(i, j) ∈ R is a normalization constant.
The posterior context for pixel (i, j), ĉql (i, j) ∈ RC , is the weighted sum:
ĉql (i, j) = α q p→l(i, j)c q l (i, j) + ∑ m≥l αqm→l(i, j)hm(i, j). (18)
To scale the deep variational model with ease, we use the following normalization:
ĉql ← ĉ q l +Gelu(LayerNorm(ĉ q l )), (19)
where Gelu is the GELU non-linearity (Hendrycks & Gimpel, 2016) and LayerNorm a layer normalization operation (Ba et al., 2016).
At the beginning of the training, we let the inference model rely on nearby dependencies, as captured by cql , by introducing the residual connection:
ĉql ← c q l + γ q l ĉ q l , (20)
where γql is a learnable scalar parameter initialized to zero.
We adopt the Gaussian residual parametrization between the prior and the posterior proposed by Vahdat & Kautz (2020). The prior is given by:
p(zl | z<l) = N (µ(cpl ),σ(c p l )). (21)
The posterior is then given by:
q(zl | x, z<l) = N (µ(cpl ) + ∆µ(ĉ q l ),σ(c p l )∆σ(ĉ q l )), (22)
where the summation and multiplication are pointwise, and cql is defined in Equation 20. µ(·), σ(·), ∆µ(·), and ∆σ(·) are transformations implemented as convolutions. The inference procedure is also described in detail in Algorithm 3.
A.2 SPATIALLY NON-LOCAL VARIATIONAL LAYERS
In this section, we provide the formal description of the non-local blocks in the recidual cells of encoder and decoder. As shown in Figure 3 and explained below, the output of each block is scaled and added back to the input feature.
Let c ∈ RH×W×C a context feature. We treat c as a sequence of N , with N = H × W , C− dimensional features, such that c ∈ RN×C . The non-local block maps c to a feature v ∈ RN×C of the same dimension by taking into account the response of all the locations in the sequence.
The context feature c is first mapped to two feature spaces of a lower dimension Q, with Q << C, through a key α and a query β linear transformation:
α(c) = cWα, (23) β(c) = cWβ , (24)
where the linear transformations Wα ∈ RC×Q, Wβ ∈ RC×Q are implemented as 1 × 1 convolutions, and α(c) ∈ RN×Q, β(c) ∈ RN×Q. The energy matrix E(c) ∈ RN×N is computed as:
E(c) = β(c)αT (c). (25)
Each element Ei,j(c) = βi(c) × αTj (c), where βi is the i−th row of β, reflects the relevance of pixel j to pixel i. The attention distribution is computed by a scaled softmax row normalization, such that the corresponding attention score Ai,j(c) is :
Ai,j(c) = exp(ωβi(c)α
T j (c))
Z(i) , (26)
Z(i) = N∑
j′=1
exp(ωβi(c)α T j′(c)). (27)
ω ∈ R is learnable scalar parameter initialized to one. c is also linearly projected to an embedding space via a transformation η:
η(c) = cWη, (28)
where Wη ∈ RC×C and η(c) ∈ RN×C . Wη is implemented as a 1× 1 convolution.
The final output v ∈ RN×C is:
v = A(c)η(c). (29)
A(c) ∈ RN×N is the matrix of the attention scores defined in Equation 27. Finally, v represents a scaled, residual mapping of c such that the final output is:
c← c+ γv, (30)
where γ ∈ R is a learnable scalar parameter initialized to zero.
A.3 ALGORITHMS
Algorithms 1, 2, and 3 summarize the inference procedure of our model. T pl and T q l refer to a block of ResNet cells (Figure 3). F d, F pl , and F q l refer to a single convolution computing the parameters of the data, prior and posterior distribution respectively. ⊕ is a merging operator unless one of its operands is zero, in which case it corresponds to an identity mapping.
Algorithm 1 Infer This algorithm computes a lower bound on the marginal data loglikelihood (Equation 2).
1: Inputs 2: x: The data. 3: h, kq ← Bottom−Up Pass (x) (Algo. 2). 4: cp, z, p(z), q(z | x)← Top−Down Pass ( h, kq ) (Algo. 3). 5: cpL+1← T p L+1(c p L ⊕ zL). 6: θ← F d(cpL+1). 7: p(x | z) ≜ p(x;θ). 8: ELBO ≈ log p(x | z)−DKL(q(z | x) ∥ p(z)). 9: Return
10: ELBO: The evidence lower bound.
Algorithm 1 computes the optimization objective of Equation 2. It consists of three main steps. During the bottom-up pass described in Algorithm 2 (see also left part of Figures 1a, 1b), the data x are passed through a sequence of ResNet transformations T ql , that will be used by the stochastic layers of the VAE hierarchy when forming the posterior distribution, in a reverse order. Note that in Algorithm 2, kqL+1 is set to zero since layer L has access only to its own hL and it is not connected with another layer from the bottom. Algorithms 1 and 2 are very similar to that of typical deep VAEs. The only difference is that the ResNet transformations are also producing the data keys kq along with the data features h. The second, top-down phase of Algorithm 1 infers samples of the
Algorithm 2 Bottom-Up Pass This algorithm computes a sequence of deterministic, hidden features and keys of the data.
1: Inputs 2: x: The data. 3: Set hL+1 ≡ x and kqL+1 ≡ 0. 4: for l = L,L− 1, . . . , 1 do 5: [hl, k q l ]← T q l (hl+1 ⊕ k q l+1). 6: end for 7: Return 8: h ≜ {hl}Ll=1: The hidden data features. 9: kq ≜ {kql }Ll=1: The data keys.
latent variables z along with the prior and posterior distributions. It is described in Algorithm 3 and explained in detail below. In Algorithm 1, cpL encapsulates latent information of z<L. Along with zL, they feed the ResNet block T p L+1 succeeded by the convolution F
d to compute the conditional data likelihood p(x | z) that is parameterized by θ. Algorithm 3 describes the top-down pass that is also visualized in the right part of Figures 1a, 1b. The layers are traversed from the top (l = 0) to the bottom-up (l = L), sampling latent variables zl from the posterior distribution and computing context features c p l that contain processed latent information of previous layers. The prior distribution is also computed in order to obtain the prior regularization term DKL(q(z | x) ∥ p(z)) of the objective function in Equation 2. The first layer does not receive latent information or context from a previous layer, therefore it sets z0 and c p 0 to zero. Similarly, since there is no other layer in the generative network to connect with, it does not produce a query sp1 to attend with. The last layer does not pass any prior information to a subsequent layer, therefore it does not compute a key kpL. Similarly, the last layer can use only its own data features hL. Therefore, the generative portion of the layer does not compute a query for the inference portion setting sqL ≡ 0. Each layer l, unless in a marginal case described above, computes four types of features kpl , s p l , s q l and cpl . Key features k p l are used at the depth-wise Attend step of next layers > l. s p l is a query to the generative network of previous layers < l. sql is a query to the inference network of current and next layers ≥ l. Finally, cpl are stochastic features that, along with s q l , will be used to form the condition of the prior distribution (Line 6). We note here that sql is used both to form the condition of the prior ĉpl and to query the inference network when forming the condition of the posterior ĉ q l . A layer in a deep VAE that is not attention-guided does not produce kpl , s q l , s p l and the computation falls into the “else” cases of Algorithm 3 (Lines 15, 26).
In Line 11, the generative network queries previous layers (via spl ) to identify latent context features cpl′ represented by keys k p l′ that are most critical when forming its prior beliefs. The resulting feature ĉpl , after being normalized in Line 12, rectifies the initial context c p l by the residual connection of Line 13. The initial prior context cpl is being used by next layers while the attention-guided context ĉpl is the conditioning factor of the prior distribution formed in Lines 17, 18.
A similar procedure takes place to form the posterior distribution. cql is the initial posterior context that merges deterministic information h and stochastic, latent information ĉpl , as seen in Lines 20, 26. cql is updated with an attention-driven feature computed in Line 22 by the residual connection of Line 24. In Line 29, the residual parametrization of the posterior, as proposed by (Vahdat & Kautz, 2020) and also described in Equation 22, is derived.
Algorithm 3 Top-Down Pass This algorithm infers a sequence of stochastic, latent representations of the data.
1: Inputs 2: h ≜ {hl}Ll=1: The hidden data features. 3: kq ≜ {kql }Ll=1: The data keys. 4: Set z0 ≡ 0, cp0 ≡ 0, s p 1 ≡ 0, s q L ≡ 0, and k p L ≡ 0. 5: for l = 1, 2, . . . , L do 6: [sql , c p l , s p l , k p l ]← T p l (zl−1 ⊕ c p l−1). 7: cpl ← c p l ⊕ s q l .
Form the prior distribution. 8: if l > 1 then 9: cpl ← c p l +Gelu(LayerNorm(c p l )).
10: cpl−1 ← LayerNorm ( cpl−1 ) .
11: ĉpl ← Attend ( {cpl′} l−1 l′=1, s p l , {k p l′} l−1 l′=1 ) . 12: ĉpl ← ĉ p l +Gelu(LayerNorm(ĉ p l )). 13: ĉpl ← c p l + γ p l ĉ p l . 14: else 15: ĉpl ← c p l . 16: end if 17: [µpl , σ p l ]← F p l (ĉ p l ). 18: p(zl | z<l) = N (µpl ,σ p l ).
Form and sample from the posterior distribution. 19: if l < L then 20: [cql , k p,q l ]← hl ⊕ ĉ p l . 21: cql ← c q l +Gelu(LayerNorm(c q l )).
22: ĉql ← Attend ( {h}Ll′=l ∪ {c q l }, s q l , {k q l′}Ll′=l ∪ {k p,q l } ) . 23: ĉql ← ĉ q l +Gelu(LayerNorm(ĉ q l )). 24: ĉql ← c q l + γ q l ĉ q l . 25: else 26: ĉql ← hl ⊕ ĉ p l . 27: end if 28: [∆µql , ∆σ q l ]← F q l (ĉ q l ). 29: q(zl | x, z<l) = N (µpl +∆µ q l ,σ p l ∆σ q l ). 30: zl ∼ q(zl | x, z<l). 31: end for 32: Return 33: cp ≜ {cpl }Ll=1: The latent context features. 34: z ≜ {zl}Ll=1: The inferred latent variables. 35: p(z) = ∏ l p(zl | z<l): The prior distribution of the latent variables.
36: q(z | x) = ∏
l q(zl | x, z<l): The approximate posterior distribution of the latent variables.
B IMPLEMENTATION DETAILS
The experiments of Section 3.1.1 are run on NVIDIA GeForce RTX 2080 Ti while the experiments of Sections 3.1.2 and 3.2 are run on 32GB V100-SXM2. For all the experiments, we use the AdaMax (Kingma & Ba, 2014) optimizer with the default parameters for training. The learning rate is decayed according to the cosine schedule with warm-up during the first 5 epochs. When we train for 900 epochs, we use a cosine decay schedule with restarts with T0 = 300 and Tmult = 2 following the notation of Loshchilov & Hutter (2017). We apply weight normalization (Salimans & Kingma, 2016) in all our models. We use the Swish (Ramachandran et al., 2017) activation function in the ResNet cells of the architecture.
Table 6 summarizes the main training and architectural hyperparameters for the experiments presented in Section 3. However, it should be noted that due to the heavy computing requirements, we do not exhaustively optimize the hyperparameters. Therefore, the results reported could potentially be further improved.
KL Annealing. We apply KL annealing (Sønderby et al., 2016) for the first 16 training epochs starting from 0.1 to 1. This technique introduces a scheduled regularization coefficient β for the KL-divergence. Formally, the regularized ELBO objective becomes:
Eq[log p(x | z)]− βDKL(q(z | x) ∥ p(z)), β0 ≤ β ≤ 1, β0 < 1, (31)
where β linearly increases from β0 to 1 for a number of epochs at the beginning of the training.
Variational Distributions. We use Gaussian prior and posterior distributions connected via a residual parametrization, see Equation 22. To ease training stability, we bound the log-scale logσ of the prior as reported in Table 6. In case of CIFAR-10, we also apply additive zero mean, Gaussian noise to the prior scale. The mean µ and the log-scale logσ are jointly learned by using a shared convolution. In particular, a 1× 1 convolution with an ELU activation is used for the prior parameters. For the posterior parameters of all but the first layer, two 3× 3 convolutions with an ELU non-linearity are used. For the posterior of the first layer, a single 1× 1 convoltion with no activation is used. Data Distributions. For MNIST and OMNIGLOT, we assume a logit-based parametrization of a Bernoulli distribution. For CIFAR-10, we use a mixture of discretized Logistic distributions (Salimans et al., 2017) with five mixture components. The parameters are jointly learned by a single 3× 3 convolution with an ELU activation. Pre-Processing and Post-Processing Blocks. The data x, before being passed to the stochastic hierarchy of L layers, are first pre-processed by a cascade of ResNet cells. Each block is responsible for downsampling the spatial dimension by a factor of 2. For MNIST, the image is downsampled twice by two blocks, leading to latent variables with spatial dimension 8 × 8. For OMNIGLOT and CIFAR-10, one preprocessing block is being used leading to latent spaces of dimension 16 × 16. No further downsampling is performed by the encoders in the main hierarchy. Each block consists of a series of ResNet cells as shown in Figure 3. The last cell of the block is responsible for downsampling while doubling the number of the output channels. For CIFAR-10, we interleave non-local blocks as shown in Figure 3. Symmetrically, the context of the last layer L is first being post-processed by a cascade of post-processing blocks before being passed to the data distribution of the decoder. Each such block is responsible for upsampling the context by a factor of 2, in order to mach the initial spatial dimension of the image. The upsampling operation is performed by the first residual cell while halving the number of the output channels. For MNIST and OMNIGLOT, we assume the spatially non-local residual cells of Figure 3.

heading: C ABLATION STUDIES
text: In this section, we perform ablation experiments to investigate the effect of different architectural choices on the model performance.
For the experiments in Tables 7, 8 and 10, the models were trained on CIFAR-10 for 500 epochs. We used shallower attentive VAE models of 8 layers for these experiments. We considered model instances of a varying size, with 64 and 128 channels at the beginning of the bottom-up network and at the end of the top-down network. As already noted in Section B, the number of channels is halved when a residual cell upsamples the spatial dimension and vice versa. In all cases, model instances with more channels in the ResNet modules in encoder and decoder perform significantly better.
We can also see that weight normalization (Salimans & Kingma, 2016), Table 7, and batch normalization layers interleaved with the convolutions of both the bottom-up and the top-down model, Table 8, improves performance. These results are consistent with the observations made by Vahdat & Kautz (2020). Moreover, their effect is greater on the larger models.
In Table 9, we report the performance of different activation functions. The Swish (Ramachandran et al., 2017) and GELU (Hendrycks & Gimpel, 2016) activations yield the best performance. This is in accordance with similar choices in current deep VAE architectures (Vahdat & Kautz, 2020; Child, 2020). The rest of the hyper-parameters are identical to that of Section B.
In Table 10, we take a closer look at the normalized depth-wise attention proposed in Section 2.4. The differences in the performance were more noticeable for deep VAE models of 16 layers. We train all model instances for 400 epochs. We omit the application of the normalization scheme presented in Equations 5 and 6 in the generative and/or inference network. We confirm that usage of depth-wise normalization facilitates training and helps scale the depth of the proposed architecture.

heading: D EMPIRICAL EVIDENCE OF BETTER LATENT VARIABLE UTILIZATION BY
text: ATTENTIVE VAE
In this section, we probe the capacity of attentive VAE to utilize the latent information inserted in the model. We first examine the Kullback–Leibler divergence DKL(q ∥ p) observed on the test data across the hierarchy during training. Unless it explodes, a high DKL(q ∥ p) loss term is often desirable since it leads to a smaller negative ELBO (NELBO) loss in Equation 2. This is because higher DKL(q ∥ p) indicates more informative latent factors z, and in turn, higher conditional likelihood p(x | z). For example, Kingma et al. (2016) use a modified objective function that lower bounds DKL(q ∥ p) by some free bits. Similarly, Vahdat & Kautz (2020) use a residual parametrization between the prior and the posterior to keep more latent variables active.
In this work, we tackle posterior collapse by imposing attention-driven connections between the layers. The proposed depth-wise attention naturally realizes long-range couplings between the layers at a pixel level. Therefore, it selectively preserves the most informative latent information which may lie far beyond in the hierarchy. In Figure 4, we show logDKL(q ∥ p) per layer zl for the baseline NVAE during the first 16 KL annealing epochs (left part) and for the rest of the training (right part). Similarly, in Figure 5, we show logDKL(q ∥ p) for the proposed model. Given the above plots, we make the following observations:
• Although in both models, logDKL(q ∥ p) remains large (always positive), our model presents a more balanced activation map in the latent space. In contrast, in Figure 4, we see that the first two layers are significantly much less active compared to the layers closer to p(x | z). This phenomenon is exacerbated in deeper hierarchies.
• In Figure 4, logDKL(q ∥ p) increases with depth. In contrast, in Figure 5 of our model, the first layer converges to a much higher DKL(q ∥ p) compared to layer 12 although it is much farther from p(x | z).
• In Figure 5, we notice that as the learning progresses, the attention scores can help activate some latent units. For example, layer 6 is relatively dormant at the beginning of the training, while it converges at a highly informative posterior distribution at the end.
Finally, in Table 11, we show the bits per dimension as the depth varies for our model. All models in Table 11 were trained for 500 epochs. As we can see the predictive improvement gained when doubling the size of the model from 8 to 16 layers is on par with the improvement accomplished when transitioning from a model of 2 layers to a model of 4 layers. In contrast, deep VAEs without attention experience half the amount of relative improvement, as seen in Table 1. We also note that the first two smallest models have converged during the last 100 training epochs which is not the case for the last two model instances. Therefore, the gap in the relative decrease for the models of 8 and 16 layers could be further closed by longer training.
E VISUALIZATION OF ATTENTION PATTERNS
In order to get further insights into the attention-driven inference, we visualize the attention maps proposed in this work. In Figure 6, we show the layer connectivity in the generative network as explained in Section 2.4 for some test images that belong to different classes. For the same images, in Figure 7 we illustrate the depth-wise attention scores in the inference network we describe in Section 2.5, and explain in greater detail in Section A.1. For both cases, we chose to visualize the layer which has the largest receptive field, i.e, the last layer for L = 16 which is right before the conditional likelihood p(x | zL) in the decoder, and the first layer which has access to all hidden, data-dependent feature maps of the bottom-up pass in the encoder.
This analysis validates the hypothesis made in this work and suggests the following conclusions:
• For all pixels, the layer relies greatly on the immediately above layer when forming the prior distribution, as shown in Figure 6.
• Different latent pixels of the same image can discover related latent clues that lie in different layers.
• Similarly, the connectivity patterns in the generative network vary significantly across images.
• Although the context cp14 already carries latent information from all previous layers, the decoder does not depend solely on that. Instead, it chooses to activate direct connections with layers far beyond in the hierarchy. This reinforces our hypothesis that the effect of latent variables in early layers may be obfuscated by more recent latent information leading in practice to non fully factorized prior distributions: p(z) = ∏ l p(zl | z<l).
• The inference attention scores in Figure 7 are more balanced across layers compared to the generative attention scores in Figure 6.
• Mitigation of posterior collapse as described in D is accomplished in a dual fashion. First, all layers in the bottom-up pass of the inference network can directly interact with the initial data feature maps of the last layers in the hierarchy, as shown in Figure 7. Second, early latent variables of the top layers condition the prior distribution of the latent variables in layers with closer affinity to the conditional data distribution in the decoder, as shown in Figure 6.
In Figures 8, 9, 10, we plot the attention scores among pixels that lie in the same layer as discussed in Sections 2.6 and A.2. The attention scores pertain to the non-local block of the last convolution of the last residual cell, as depicted in Figure 3, of the ResNet module in the generative portion of each layer.
We derive the following observations:
• The connectivity patterns in all layers are highly structured. This implies that the model could be benefited by sparse attention factorizations such as those proposed by Child et al. (2019), that rely on a similar assumption.
• The attention schemes vary widely across layers. For example, the activation map is more scattered in the first layer of Figure 8 compared to that of the last layer of Figure 10 which is sparser and gathered in periodic spatial locations. This may align with the functionality of the latent information as discussed in current research (Child, 2020), according to which top layers capture global, high-level features while lower layers are responsible for capturing finer details.
• Different images exhibit different spatial attention maps. The differences are more pronounced in the middle layer, as depicted in Figure 9.

heading: F RECONSTRUCTIONS AND FANTASY SAMPLES GENERATED FROM OUR MODEL
text: In this section, we qualitatively assess the Attentive VAE presented in the paper. Figures 11b and 12b illustrate reconstructed MNIST and CIFAR-10 test images from the inferred latent variables.
Figures 11c and 12c show novel MNIST and CIFAR-10 images sampled by the generative model.

Review summaries:
This paper identifies a common problem in previous VAE related models: adding more stochastic layers to an already very deep model yields small predictive improvement while substantially increasing the inference and training time. Therefore, a new model that proposes to use attention mechanisms to build more expressive variational distributions in deep probabilistic models by explicitly modelling both local and global interactions in the latent space is proposed. The model is evaluated on standard dataset MNIST and OMNIGLOT, and showed superior performance against a wide range of baseline models.

This paper improves the architecture of deep VAEs using the attention mechanism.   The attention mechanism is used in two ways: 1. layer-wise attention (attending stochastic feature maps which are conditioned on other variables within the hierarchy, interpreted as a mixture of skip connections) 2. non-local attention (attention across the spatial dimensions, increases the size of receptive field)  The authors demonstrate the effectiveness of their architectural changes by challenging current sota deep VAEs on MNIST, OMNIGLOT and CIFAR-10. Notably, they outperform the state-of-the-art methods (in likelihood) on CIFAR-10 using fewer layers and fewer GPU hours.   The authors provide an extensive ablation study, showing the impact of each type of attention on the training performances (test likelihood on CIFAR-10).