Recurrent Variational Auto-encoders with Gaussian Attention
Humans have an impressive ability to reason about new concepts and experiences from just a single example. In particular, humans have an ability for one-shot generalization: an ability to encounter a new concept, understand its structure, and then be able to generate compelling alternative variations of the concept. We develop machine learning systems with this important capacity by developing new deep generative models, models that combine the representational power of deep learning with the inferential power of Bayesian reasoning. We develop a class of sequential generative models that are built on the principles of feedback and attention. These two characteristics lead to generative models that are among the state-of-the art in density estimation and image generation. We demonstrate the one-shot generalization ability of our models using three tasks: unconditional sampling, generating new exemplars of a given concept, and generating new exemplars of a family of concepts. In all cases our models are able to generate compelling and diverse samples---having seen new examples just once---providing an important class of general-purpose models for one-shot machine learning.READ FULL TEXT VIEW PDF
Recurrent Variational Auto-encoders with Gaussian Attention
Consider the images in the red box in figure 1. We see each of these new concepts just once, understand their structure, and are then able to imagine and generate compelling alternative variations of each concept, similar to those drawn in the rows beneath the red box. This is an ability that humans have for one-shot generalization: an ability to generalize to new concepts given just one or a few examples. In this paper, we develop new models that possess this capacity for one-shot generalization—models that allow for one-shot reasoning from the data streams we are likely to encounter in practice, that use only limited forms of domain-specific knowledge, and that can be applied to diverse sets of problems.
There are two notable approaches that incorporate one-shot generalization. Salakhutdinov et al. (2013)
developed a probabilistic model that combines a deep Boltzmann machine with a hierarchical Dirichlet process to learn hierarchies of concept categories as well as provide a powerful generative model. Recently,Lake et al. (2015)
presented a compelling demonstration of the ability of probabilistic models to perform one-shot generalization, using Bayesian program learning, which is able to learn a hierarchical, non-parametric generative model of handwritten characters. Their approach incorporates specific knowledge of how strokes are formed and the ways in which they are combined to produce characters of different types, exploiting similar strategies used by humans.Lake et al. (2015)
see the capacity for one-shot generalization demonstrated by Bayesian programming learning ‘as a challenge for neural models’. By combining the representational power of deep neural networks embedded within hierarchical latent variable models, with the inferential power of approximate Bayesian reasoning, we show that this is a challenge that can be overcome. The resulting deep generative models are general-purpose image models that are accurate and scalable, among the state-of-the-art, and possess the important capacity for one-shot generalization.
Deep generative models are a rich class of models for density estimation that specify a generative process for observed data using a hierarchy of latent variables. Models that are directed graphical models have risen in popularity and include discrete latent variable models such as sigmoid belief networks and deep auto-regressive networks (Saul et al., 1996; Gregor et al., 2014), or continuous latent variable models such as non-linear Gaussian belief networks and deep latent Gaussian models (Rezende et al., 2014; Kingma & Welling, 2014)
. These models use deep networks in the specification of their conditional probability distributions to allow rich non-linear structure to be learned. Such models have been shown to have a number of desirable properties: inference of the latent variables allows us to provide a causal explanation for the data that can be used to explore its underlying factors of variation and for exploratory analysis; analogical reasoning between two related concepts, e.g., styles and identities of images, is naturally possible; any missing data can be imputed by treating them as additional latent variables, capturing the the full range of correlation between missing entries under any missingness pattern; these models embody minimum description length principles and can be used for compression; these models can be used to learn environment-simulators enabling a wide range of approaches for simulation-based planning.
Two principles are central to our approach: feedback and attention. These principles allow the models we develop to reflect the principles of analysis-by-synthesis, in which the analysis of observed information is continually integrated with constructed interpretations of it (Yuille & Kersten, 2006; Erdogan et al., 2015; Nair et al., 2008). Analysis is realized by attentional mechanisms that allow us to selectively process and route information from the observed data into the model. Interpretations of the data are then obtained by sets of latent variables that are inferred sequentially to evaluate the probability of the data. The aim of such a construction is to introduce internal feedback into the model that allows for a ‘thinking time’ during which information can be extracted from each data point more effectively, leading to improved inference, generation and generalization. We shall refer to such models as sequential generative models. Models such as DRAW (Gregor et al., 2015), composited variational auto-encoders (Huang & Murphy, 2015) and AIR (Eslami et al., 2016) are existing models in this class, and we will develop a general class of sequential generative models that incorporates these and other latent variable models and variational auto-encoders.
Our contributions are:
We develop sequential generative models that provide a generalization of existing approaches, allowing for sequential generation and inference, multi-modal posterior approximations, and a rich new class of deep generative models.
We demonstrate the clear improvement that the combination of attentional mechanisms in more powerful models and inference has in advancing the state-of-the-art in deep generative models.
Importantly, we show that our generative models have the ability to perform one-shot generalization. We explore three generalization tasks and show that our models can imagine and generate compelling alternative variations of images after having seen them just once.
Attending to parts of a scene, ignoring others, analyzing the parts that we focus on, and sequentially building up an interpretation and understanding of a scene: these are natural parts of human cognition. This is so successful a strategy for reasoning that it is now also an important part of many machine learning systems. This repeated process of attention and interpretation, analysis and synthesis, is an important component of the generative models we develop.
In its most general form, any mechanism that allows us to selectively route information from one part of our model to another can be regarded as an attentional mechanism. Attention allows for a wide range of invariances to be incorporated, with few additional parameters and low computational cost. Attention has been most widely used for classification tasks, having been shown to improve both scalability and generalization (Larochelle & Hinton, 2010; Chikkerur et al., 2010; Xu et al., 2015; Jaderberg et al., 2015; Mnih et al., 2014; Ba et al., 2015)
. The attention used in discriminative tasks is a ‘reading’ attention that transforms an image into a representation in a canonical coordinate space (that is typically lower dimensional), with the parameters controlling the attention learned by gradient descent. Attention in unsupervised learning is much more recent(Tang et al., 2014; Gregor et al., 2015). In latent variable models, we have two processes—inference and generation—that can both use attention, though in slightly different ways. The generative process makes use of a writing or generative attention, which implements a selective updating of the output variables, e.g., updating only a small part of the generated image. The inference process makes use of reading attention, like that used in classification. Although conceptually different, both these forms of attention can be implemented with the same computational tools. We focus on image modelling and make use of spatial attention. Two other types of attention, randomized and error-based, are discussed in appendix B.
where and are 1-dimensional kernels,
indicates the tensor outer-product of the two kernels andindicates a convolution. Huang & Murphy (2015) develop occlusion-aware generative models that make use of spatial transformers in this way. When used for reading attention, spatial transformers allow the model to observe the input image in a canonical form, providing the desired invariance. When used for writing attention, it allows the generative model to independently handle position, scale and rotation of parts of the generated image, as well as their content. An direct extension is to use multiple attention windows simultaneously (see appendix).
Generative models with latent variables describe the probabilistic process by which an observed data point can be generated. The simplest formulations such as PCA and factor analysis use Gaussian latent variables
that are combined linearly to generate Gaussian distributed data points. In more complex models, the probabilistic description consists of a hierarchy of layers of latent variables, where each layer depends on the layer above in a non-linear way (Rezende et al., 2014). For deep generative models, we specify this non-linear dependency using deep neural networks. To compute the marginal probability of the data, we must integrate over any unobserved variables:
In deep latent Gaussian models, the prior distribution is a Gaussian distribution and the likelihood function is any distribution that is appropriate for the observed data, such as a Gaussian, Bernoulli, categorical or other distribution, and that is dependent in a non-linear way on the latent variables. For most models, the marginal likelihood (1) is intractable and we must instead approximate it. One popular approximation technique is based on variational inference (Jordan et al., 1999), which transforms the difficult integration into an optimization problem that is typically more scalable and easier to solve. Using variational inference we can approximate the marginal likelihood by a lower bound, which is the objective function we use for optimization:
The objective function (2) is the negative free energy, which allows us to trade-off the reconstruction ability of the model (first term) against the complexity of the posterior distribution (second term). Variational inference approximates the true posterior distribution by a known family of approximating posteriors with variational parameters . Learning now involves optimization of the variational parameters and model parameters .
Instead of optimization by the variational EM algorithm, we take an amortized inference approach and represent the distribution as a recognition or inference model, which we also parameterize using a deep neural network. Inference models amortize the cost of posterior inference and makes it more efficient by allowing for generalization across the inference computations using a set of global variational parameters . In this framework, we can think of the generative model as a decoder of the latent variables, and the inference model as its inverse, an encoder of the observed data into the latent description. As a result, this specific combination of deep latent variable model (typically latent Gaussian) with variational inference that is implemented using an inference model is referred to as a variational auto-encoder (VAE). VAEs allow for a single computational graph to be constructed and straightforward gradient computations: when the latent variables are continuous, gradient estimators based on pathwise derivative estimators are used (Rezende et al., 2014; Kingma & Welling, 2014; Burda et al., 20) and when they are discrete, score function estimators are used (Mnih & Gregor, 2014; Ranganath et al., 2014; Mansimov et al., 2016).
The generative models as we have described them thus far can be characterized as single-step models, since they are models of i.i.d data that evaluate their likelihood functions by transforming the latent variables using a non-linear, feed-forward transformation. A sequential generative model is a natural extension of the latent variable models used in VAEs. Instead of generating the latent variables of the model in one step, these models sequentially generate groups of latent variables (), i.e. using computational steps to allow later groups of latent variables to depend on previously generated latent variables in a non-linear way.
In their most general form, sequential generative models describe the observed data over time steps using a set of latent variables at each step. The generative model is shown in the stochastic computational graph of figure 2(a), and described by:
Each step generates an independent set of -dimensional latent variables (equation (3)). If we wish to condition the model on an external context or piece of side-information , then a deterministic function (equation (4)) is used to read the context-images using an attentional mechanism. A deterministic transition function introduces the sequential dependency between each of the latent variables, incorporating the context if it exists (equation (5
)). This allows any transition mechanism to be used and our transition is specified as a long short-term memory network (LSTM,Hochreiter & Schmidhuber (1997). We explicitly represent the creation of a set of hidden variables that is a hidden canvas of the model (equation (6)). The canvas function allows for many different transformations, and it is here where generative (writing) attention is used; we describe a number of choices for this function in section 3.2.3. The generated image (7) is sampled using an observation function that maps the last hidden canvas to the parameters of the observation model. The set of all parameters of the generative model is .
Given the probabilistic model (3)-(7) we can obtain an objective function for inference and parameter learning using variational inference. By applying the variational principle, we obtain the free energy objective:
where indicates the collection of all latent variables from step 1 to . We can now optimize this objective function for the variational parameters and the model parameters
, by stochastic gradient descent using a mini-batch of data. As with other VAEs, we use a single sample of the latent variables generated fromwhen computing the Monte Carlo gradient. To complete our specification, we now specify the hidden-canvas functions and the approximate posterior distribution .
The canvas transition function (6
) updates the hidden canvas by first non-linearly transforming the current hidden state of the LSTM(using a function ) and fuses the result with the existing canvas . In this work we use hidden canvases that have the same size as the original images, though they could be either larger or smaller in size and can have any number of channels (four in this paper). We consider two ways with which to update the hidden canvas:
Additive Canvas. As the name implies, an additive canvas updates the canvas by simply adding a transformation of the hidden state to the previous canvas state . This is a simple, yet effective (see results) update rule:
Gated Recurrent Canvas.
The canvas function can be updated using a convolutional gated recurrent unit (CGRU) architecture(Kaiser & Sutskever, 2015), which provides a non-linear and recursive updating mechanism for the canvas and are simplified versions of convolutional LSTMs (further details of the CGRU are given in appendix B). The canvas update is:
In both cases, the function is a writing or generative attention function, that we implement as a spatial transformer; inputs to the spatial transformer are its affine parameters and a image to be transformed, both of which are provided by the LSTM output.
The final phase of the generative process transforms the hidden canvas at the last time step into the parameters of the likelihood function using the output function . Since we use a hidden canvas that is the same size as the original images but that have a different number of filters, we implement the output function as a convolution. When the hidden canvas has a different size, a convolutional network is used instead.
We use a structured posterior approximation that has an auto-regressive form, i.e. . We implement this distribution as an inference network parameterized by a deep network. The specific form we use is:
At every step of computation, we form a low-dimensional representation of the input image using a non-linear transformation of the input image and the hidden state of the model.This function is reading or recognition attention using a spatial transformer, whose affine parameters are given by the LSTM output. The result of reading is a sprite that is then combined with the previous state through a further non-linear function to produce the mean
and varianceof a -dimensional diagonal Gaussian distribution. We denote all the parameters of the inference model by . Although the conditional distributions are Gaussian, the joint posterior posterior is non-Gaussian and multi-modal due to the non-linearities used, enabling more accurate inference.
The above sequential generative model and inference is a generalization of existing models such as DRAW (Gregor et al., 2015) , composited VAEs (Huang & Murphy, 2015) and AIR (Eslami et al., 2016). This generalization has a number of differences and important properties. One of the largest deviations is the introduction of the hidden canvas into the generative model that provides an important richness to the model, since it allows a pre-image to be constructed in a hidden space before a final corrective transformation, using the function , is used. The generative process has an important property that allows the model be sampled without feeding-back the results of the canvas to the hidden state —such a connection is not needed and provides more efficiency by reducing the number of model parameters. The inference network in our framework is also similarly simplified. We do not use a separate recurrent function within the inference network (like DRAW), but instead share parameters of the LSTM from the prior—the removal of this additional recursive function has no effect on performance.
Another important difference between our framework and existing frameworks is the type of attention that is used. Gregor et al. (2015) use a generative attention based on Gaussian convolutions parameterized by a location and scale, and Tang et al. (2014) use 2D similarity transformations. We use a much more powerful and general attention mechanism based on spatial transformers (Jaderberg et al., 2015; Huang & Murphy, 2015).
The overall complexity of the algorithm described matches the typical complexity of widely-used methods in deep learning. For images of size , the spatial transformer has a complexity that is linear in the number of pixels of the attention window. For a attention window, with , the spatial transformer has a complexity of , for sequential steps and data points. All other components have the standard quadratic complexity in the layer size, hence for layers with average size , this gives a complexity of .
We first show that our models are state-of-the-art, obtaining highly competitive likelihoods, and are able to generate high-quality samples across a wide range of data sets with different characteristics.
For all our experiments, our data consists of binary images and we use use a Bernoulli likelihood to model the probability of the pixels. In all models we use 400 LSTM hidden units. We use kernels for the spatial transformer, whether used for recognition or generative attention. The latent variable are 4-dimensional Gaussian distributions and we use a number of steps that vary from 20-80. The hidden canvas has dimensions that are the size of the images with four channels. We present the main results here and any additional results in Appendix A. All the models were trained for approximatively 800K iterations with mini-batches of size 24. The reported likelihood bounds for the training set are computed by averaging the last 1K iterations during training. The reported likelihood bounds for the test set were computed by averaging the bound for
random samples (sampled with replacement) and the error bars are the standard-deviations of the mean.
We highlight the behaviour of the models using two data sets based on the MNIST benchmark. The first experiment uses the binarized MNIST data set ofSalakhutdinov & Murray (2008), that consists of binary images with 50,000 training and 10,000 test images. Table 1 compares the log-likelihoods on this binarized MNIST data set using existing models, as well as the models developed in this paper (with variances of our estimates in parentheses). The sequential generative model that uses the spatially-transformed attention with the CGRU hidden canvas provides the best performance among existing work on this data set. We show samples from the model in figure 3.
We form a multi-MNIST data set of images that consists of two MNIST digits placed at random locations in the image (having adapted the cluttered MNIST generator from Mnih et al. (2014) to procedurally generate the data). We compare the performance in table 2 and show samples from this model in figure 3. This data set is much harder than MNIST to learn, with much slower convergence. The additive canvas with spatially-transformed attention provides a reliable way to learn from this data.
|From Gregor et al. (2015) and Burda et al. (20)|
|VAE + HVI/Norm Flow||85.10|
|DRAW (64 steps, no attention)||87.40|
|DRAW (64 steps, Gaussian attention)||80.97|
|IWAE (2 layers; 50 particles )|
|Sequential generative models|
Importance of each step
These results also indicate that longer sequences can lead to better performance. Every step taken by the model adds a term to the objective function (2) corresponding to the KL-divergence between the prior distribution and the contribution to the approximate posterior distribution at that step. Figure 5 shows the KL-divergence for each iteration for two models on MNIST up to 20 steps. The KL-divergence decays towards the end of the sequence, indicating that the latent variables have diminishing contribution to the model as the number of steps grow. Unlike VAEs where we often find that there are many dimensions which contribute little to the likelihood bound, the sequential property allows us to more efficiently allocate and decide on the number of latent variables to use and means of deciding when to terminate the sequential computation.
Unlike MNIST, which has a small number of classes with many images of each class and a large amount of data, the omniglot data set (Lake et al., 2015) consists of binary images across 1628 classes with just 20 images per class. This data set allows us to demonstrate that attentional mechanisms and better generative models allow us to perform well even in regimes with larger images and limited amounts of data.
There are two versions of the omniglot data that have been previously used for the evaluation of generative models. One data set used by Burda et al. (20) consists of images, but is different to that of Lake et al. (2015). We compare the available methods on the dataset from Burda et al. (20) in table 3 and find that the sequential models perform better than all competing approaches, further establishing the effectiveness of these models. Our second evaluation uses the dataset of Lake et al. (2015), which we downsampled to using a max-pooling. We compare different sequential models in table 4 and again find that spatially-transformed attention is a powerful general purpose attention and that the additive hidden canvas performs best.
|From Burda et al. (20)|
|VAE (2 layer, 5 samples)||106.31|
|IWAE (2 layer, 50 samples)||103.38|
|RBM (500 hidden)||100.46|
|Seq Gen Model (20 steps, ST, additive)||96.5|
|Seq Gen Model (80 steps, ST, additive)||95.5|
The Multi-PIE dataset (Gross et al., 2010) consists of RGB face images from various viewpoints. We have converted the images to grayscale and trained our model on a subset comprising of all 15-viewpoints but only 3 out of the 19 illumination conditions. Our simplification results in training samples and test samples. Samples from this model are shown in figure 7
and are highly compelling, showing faces in different orientations, different genders and are representative of the data. The model was trained using the logit-normal likelihood as inRezende & Mohamed (2015).
Lake et al. (2015) introduce three tasks to evaluate one-shot generalization, testing weaker to stronger forms of generalization. The three tasks are: (1) unconditional (free) generation, (2) generation of novel variations of a given exemplar, and (3) generation of representative samples from a novel alphabet. Lake et al. (2015) conduct human evaluations as part of their assessment, which is important in contrasting the performance of models against the cognitive ability of humans; we do not conduct human benchmarks in this paper (human evaluation will form part of our follow-up work). Our focus is on the machine learning of one-shot generalization and the computational challenges associated with this task.
1. Unconditional Generation.
This is the same generation task reported for the data sets in the previous section. Figure 8 shows samples that reflect the characteristics of the omniglot data, showing a variety of styles including rounded patterns, line segments, thick and thin strokes that are representative of the data set. The likelihoods reported in tables 3 and 4 quantitatively establish this model as among the state-of-the-art.
2. Novel variations of a given exemplar.
This task corresponds to figure 5 in Lake et al. (2015)). At test time, the model is presented with a character of a type it has never seen before (was not part of its training set), and asked to generate novel variations of this character. To do this, we use a conditional generative model (figure 2(b), equation (4)). The context is the image that we wish the model to generate new exemplars of. To expose the boundaries of our approach, we test this under weak and strong one-shot generalization tests:
We use a data set whose training data consists of all available alphabets, but for which three character types from each alphabet have been removed to form the test set (3000 characters). This is a weak one-shot generalization test where, although the model has never seen the test set characters, it has seen related characters from the same alphabet and is expected to transfer that knowledge to this generation task.
We use exactly the data split used by Lake et al. (2015), which consists of 30 alphabets as the training set and the remaining 20 alphabets as the test set. This is a strong one-shot generalization test, since the model has seen neither the test character nor any alphabets from its family. This is a hard test for our model, since this split provides limited training data, making overfitting easier, and generalization harder.
We use two alternative training-test split of the data, a 40-10 and 45-5 split. We can examine the spectrum of difficulty of the previous one-shot generalization task by considering these alternative splits.
We show the model’s performance on the weak generalization test in figure 9, where the first row shows the exemplar image, and the subsequent rows show the variations of that image generated by the model. We show generations for the strong generalization test in figure 10. Our model also generates visually similar and reasonable variations of the image in this case. Unlike the model of Lake et al. (2015), which uses human stroke information and a model structured around the way in which humans draw images, our model is applicable to any image data, with the only domain specific information that is used being that the data is spatially arranged (which is exploited by the convolution and attention). This test also exposes the difficulty that the model has in coping with small amounts of data. We compare the difference between train and test log-likelihoods for the various data splits in figure 5
. We see that there is a small gap between the training and test likelihoods in the regime where we have more data (45-5 split) indicating no overfitting. There is a large gap for the other splits, hence a greater tendency for overfitting in the low data regime. An interesting observation is that even for the cases where there is a large gap between train and test likelihood bounds (figure 5), the examples generated by the model (figure 10, left and middle) still generalize to unseen character classes. Data-efficiency is an important challenge for the large parametric models that we use and one we hope to address in future.
3. Representative samples from a novel alphabet.
This task corresponds to figure 7 in Lake et al. (2015), and conditions the model on anywhere between 1 to 10 samples of a novel alphabet and asks the model to generate new characters consistent with this novel alphabet. We show here the hardest form of this test, using only 1 context image. This test is highly subjective, but the model generations in figure 11 show that it is able to pick up common features and use them in the generations.
We have emphasized the usefulness of deep generative models as scalable, general-purpose tools for probabilistic reasoning that have the important property of one-shot generalization. But, these models do have limitations. We have already pointed to the need for reasonable amounts of data. Another important consideration is that, while our models can perform one-shot generalization, they do not perform one-shot learning
. One-shot learning requires that a model is updated after the presentation of each new input, e.g., like the non-parametric models used byLake et al. (2015) or Salakhutdinov et al. (2013). Parametric models such as ours require a gradient update of the parameters, which we do not do. Instead, our model performs a type of one-shot inference that during test time can perform inferential tasks on new data points, such as missing data completion, new exemplar generation, or analogical sampling, but does not learn from these points. This distinction between one-shot learning and inference is important and affects how such models can be used. We aim to extend our approach to the online and one-shot learning setting in future.
We have developed a new class of general-purpose models that have the ability to perform one-shot generalization, emulating an important characteristic of human cognition. Sequential generative models are natural extensions of variational auto-encoders and provide state-of-the-art models for deep density estimation and image generation. The models specify a sequential process over groups of latent variables that allows it to compute the probability of data points over a number of steps, using the principles of feedback and attention. The use of spatial attention mechanisms substantially improves the ability of the model to generalize. The spatial transformer is a highly flexible attention mechanism for both reading and writing, and is now our default mechanism for attention in generative models. We highlighted the one-shot generalization ability of the model over a range of tasks that showed that the model is able to generate compelling and diverse samples, having seen new examples just once. However there are limitations of this approach, e.g., still needing a reasonable amount of data to avoid overfitting, which we hope to address in future work.
We thank Brenden Lake and Josh Tenenbaum for insightful discussions. We are grateful to Theophane Weber, Ali Eslami, Peter Battaglia and David Barrett for their valuable feedback.
Learning wake-sleep recurrent attention models.In NIPS, pp. 2575–2583, 2015.
Importance weighted autoencoders.ICLR, 20.
What and where: A Bayesian inference theory of attention.Vision research, 50(22):2233–2247, 2010.
DRAW: A recurrent neural network for image generation.In ICML, 2015.
Stochastic backpropagation and approximate inference in deep generative models.In ICML, 2014.
On the quantitative analysis of deep belief networks.In ICML, pp. 872–879, 2008.
Journal of artificial intelligence research, 4(1):61–76, 1996.
The SVHN dataset (Netzer et al., 2011) consists of RGB images from house numbers.
Randomized attention. The simplest attention randomly selects patches from the input image, which is the simplest way of implementing a sparse selection mechanism. Applying dropout regularisation to the input layer of deep models would effectively implement this type of attention (a hard attention that has no learning). In data sets like MNIST this attention allows for competitive learning of the generative model if the model is allowed to attend to a large number of patches; see this video https://www.youtube.com/watch?v=W0R394wEUqQ.
Error-based attention. One of the difficulties with attention mechanisms is that for large and sparse images, there can be little gradient information available, which can cause the attentional selection to become stuck. To address this issue, previous approaches have used particle methods (Tang et al., 2014)
and exploration techniques from reinforcement learning(Mnih et al., 2014) to infer the latent variables that control the attentional, and allow it to jump more easily to relevant parts of the input. A simple way of realizing this, is to decide where to attend to by jumping o places where the model has made the largest reconstruction errors. To do this, we convert the element-wise reconstruction error at every step into a probability map of locations to attend to at the next iteration:
where is the reconstruction error of the th pixel, is the reconstructed image at iteration , is the current target image, is the spatial average of , and is the spatial standard deviation of . This attention is suited to models of sparse images ; see this video https://www.youtube.com/watch?v=qb2-73OHuWA for an example of a model with this attention mechanism. In this type of hard-attention, a policy does not need to be learned, since a new one is obtained after every step based on the reconstruction error and effectively allows every step to work more efficiently towards reducing the reconstruction error. It also overcomes the problem of limited gradient information in large, sparse images, since this form of attention will have a saccadic behaviour since it will be able to jump to any part of the image that has high error.
Multiple spatial attention. A simple generalization of using a single spatial transformer is to have multiple STs that are additively combined:
where is a context that conditions all STs. This module allows the generative model to write or read at multiple locations simultaneously.
The CGRU of Kaiser & Sutskever (2015) has the following form:
where the symbols indicates the element-wise product,
a size-preserving convolution with stride of, and
is the sigmoid function. The matrices, and are kernels. The number of filters used for the hidden canvas is specified on section 4.