This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Uncertainty in Neural Processes

Saeid Naderiparizi1, Kenny Chiu2, Benjamin Bloem-Reddy2, Frank Wood1,3,4
1Department of Computer Science, University of British Columbia
2Department of Statistics, University of British Columbia
3MILA
4CIFAR AI Chair
{saeidnp, fwood}@cs.ubc.ca, {kenny.chiu, benbr}@stat.ubc.ca
Abstract

We explore the effects of architecture and training objective choice on amortized posterior predictive inference in probabilistic conditional generative models. We aim this work to be a counterpoint to a recent trend in the literature that stresses achieving good samples when the amount of conditioning data is large. We instead focus our attention on the case where the amount of conditioning data is small. We highlight specific architecture and objective choices that we find lead to qualitative and quantitative improvement to posterior inference in this low data regime. Specifically we explore the effects of choices of pooling operator and variational family on posterior quality in neural processes. Superior posterior predictive samples drawn from our novel neural process architectures are demonstrated via image completion/in-painting experiments.

1 Introduction

What makes a probabilistic conditional generative model good? The belief that a generative model is good if it produces samples that are indistinguishable from those that it was trained on (Hinton, 2007) is widely accepted, and understandably so. This belief also applies when the generator is conditional, though the standard becomes higher: conditional samples must be indistinguishable from training samples for each value of the condition.

Consider an amortized image in-painting task in which the objective is to fill in missing pixel values given a subset of observed pixel values. If the number and location of observed pixels is fixed, then a good conditional generative model should produce sharp-looking sample images, all of which should be compatible with the observed pixel values. If the number and location of observed pixels is allowed to vary, the same should remain true for each set of observed pixels. Recent work on this problem has focused on reconstructing an entire image from as small a conditioning set as possible. As shown in Fig. 1, state-of-the-art methods (Kim et al., 2018) achieve high-quality reconstruction from as few as 30 conditioning pixels in a 1024-pixel image.

Our work starts by questioning whether reconstructing an image from a small subset of pixels is always the right objective. To illustrate, consider the image completion task on handwritten digits. A small set of pixels might, depending on their locations, rule out the possibility that the full image is, say, 1, 5, or 6. Human-like performance in this case would generate sharp-looking sample images for all digits that are consistent with the observed pixels (i.e., 0, 2-4, and 7-9). Observing additional pixels will rule out successively more digits until the only remaining uncertainty pertains to stylistic details. The bottom-right panel of Fig. 1 demonstrates this type of “calibrated” uncertainty.

We argue that in addition to high-quality reconstruction based on large conditioning sets, amortized conditional inference methods should aim for meaningful, calibrated uncertainty, particularly for small conditioning sets. For different problems, this may mean different things. In this work, we focus on the image in-painting problem, and define well calibrated uncertainty to be a combination of two qualities: high sample diversity for small conditioning sets; and sharp-looking, realistic images for any size of conditioning set. As the size of the conditioning set grows, we expect the sample diversity to decrease and the quality of the images to increase. We note that this emphasis is different from the current trend in the literature, which has focused primarily on making sharp and accurate image completions when the size of the conditioning context is large (Kim et al., 2018).

To better understand and make progress toward our aim, we employ posterior predictive inference in a conditional generative latent-variable model, with a particular focus on neural processes (NPs) (Garnelo et al., 2018a; b). We find that particular architecture choices can result in markedly different performance. In order to understand this, we investigate posterior uncertainty in NP models, and we use our findings to establish new best practices for NP amortized inference artifacts with well-calibrated uncertainty. In particular, we demonstrate improvements arising from a combination of max pooling, a mixture variational distribution, and a “normal” amortized variational inference objective.

Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Figure 1: Representative image in-painting results for CelebA and MNIST. From left to right, neural process (NP) (Garnelo et al., 2018b), attentive neural process (ANP) (Kim et al., 2018), and ours. Top rows show context sets of given pixels, ranging from very few pixels to all pixels. In each panel the ground truth image (all pixels) is in the upper right corner. The rows correspond to i.i.d. samples from the corresponding image completion model given only the pixels shown in the top row of the same column. Our neural process with semi-implicit variational inference and max pooling produces results with the following characteristics: 1) the images generated with a small amount of contextual information are “sharper” and more face- and digit-like than NP results and 2) there is greater sample diversity across the i.i.d. samples than those from the ANP. This kind of “calibrated uncertainty” is what we target throughout.

2 Amortized Inference for Conditional Generative Models

Our work builds on amortized inference (Gershman & Goodman, 2014; Kingma & Welling, 2014), probabilistic meta-learning (Gordon et al., 2019), and conditional generative models in the form of neural processes (Garnelo et al., 2018b; Kim et al., 2018). This section provides background.

Let (𝒙𝒞,𝒚𝒞)={(xi,yi)}i=1n({\bm{x}}_{{\mathcal{C}}},{\bm{y}}_{{\mathcal{C}}})=\{(x_{i},y_{i})\}_{i=1}^{n} and (𝒙𝒯,𝒚𝒯)={(xj,yj)}j=1m({\bm{x}}_{{\mathcal{T}}},{\bm{y}}_{{\mathcal{T}}})=\{(x^{\prime}_{j},y^{\prime}_{j})\}_{j=1}^{m} be a context set and target set respectively. In image in-painting, the context set input 𝒙𝒞{\bm{x}}_{{\mathcal{C}}} is a subset of an image’s pixel coordinates, the context set output 𝒚𝒞{\bm{y}}_{{\mathcal{C}}} are the corresponding pixel values (greyscale intensity or colors), the target set input 𝒙𝒯{\bm{x}}_{{\mathcal{T}}} is a set of pixel coordinates requiring in-painting, and the target set output 𝒚𝒯{\bm{y}}_{{\mathcal{T}}} is the corresponding set of target pixel values. The corresponding graphical model is shown in Fig. 2.

The goal of amortized conditional inference is to rapidly approximate, at “test time,” the posterior predictive distribution

pθ(𝒚𝒯|𝒙𝒯,𝒙𝒞,𝒚𝒞)=pθ(𝒚𝒯|𝒙𝒯,z)pθ(z|𝒙𝒞,𝒚𝒞)𝑑z.p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})=\int p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},z)p_{\theta}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})dz\;. (1)

We can think of the latent variable zz as representing a problem-specific task-encoding. The likelihood term pθ(𝒚𝒯|𝒙𝒯,z)p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},z) shows that the encoding parameterizes a regression model linking the target inputs to the target outputs. In the NP perspective, zz is a function and Eq. 1 can be seen as integrating over the regression function itself, as in Gaussian process regression (Rasmussen, 2003).

Variational inference

There are two fundamental aims for amortized inference for conditional generative models: learning the model, parameterized by θ\theta, that produces good samples, and producing an amortization artifact, parameterized by ϕ\phi, that can be used to approximately solve Eq. 1 quickly at test time. Variational inference techniques couple the two learning problems. Let 𝒚{\bm{y}} and 𝒙{\bm{x}} be task-specific output and input sets, respectively, and assume that at training time we know the values of 𝒚{\bm{y}}. We can construct the usual single-training-task evidence lower bound (ELBO) as

logpθ(𝒚|𝒙)𝔼𝒛qϕ(z|𝒙,𝒚)[logpθ(𝒚|z,𝒙)pθ(z)qϕ(z|𝒙,𝒚)].\log p_{\theta}({\bm{y}}|{\bm{x}})\geq{\textstyle\mathbb{E}_{{\bm{z}}\sim q_{\phi}(z|{\bm{x}},{\bm{y}})}\left[\log\frac{p_{\theta}({\bm{y}}|z,{\bm{x}})p_{\theta}(z)}{q_{\phi}(z|{\bm{x}},{\bm{y}})}\right]}\;. (2)

Summing over all training examples and optimizing Eq. 2 with respect to ϕ\phi learns an amortized inference artifact that takes a context set and returns a task embedding; optimizing with respect to θ\theta learns a problem-specific generative model. Optimizing both simultaneously results in an amortized inference artifact bespoke to the overall problem domain.

At test time the learned model and inference artifacts can be combined to perform amortized posterior predictive inference, approximating Eq. 1 with

pθ(𝒚𝒯|𝒙𝒯,𝒙𝒞,𝒚𝒞)pθ(𝒚𝒯|𝒙𝒯,z)qϕ(z|𝒙𝒞,𝒚𝒞)𝑑z.p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})\approx\int p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},z)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})dz\;. (3)

Crucially, given an input (𝒙𝒞,𝒚𝒞)({\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}), sampling from this distribution is as simple as sampling a task embedding zz from qϕ(z|𝒙𝒞,𝒚𝒞)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) and then passing the sampled zz to the generative model pθ(𝒚𝒯|𝒙𝒯,z)p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},z) to produce samples from the conditional generative model.

Refer to caption
Figure 2: Graphical model for a single neural process task. 𝒞{\mathcal{C}} is the task “context” set of input/output pairs (xi,yi)(x_{i},y_{i}) and 𝒯{\mathcal{T}} is a target set in which only the input values are known.
Meta-learning

The task-specific problem becomes a meta-learning problem when learning a regression model θ\theta that performs well on multiple tasks with the same graphical structure, trained on data for which the target outputs {yj}\{y^{\prime}_{j}\} are observed as well. In training our in-painting models, following conventions in the literature (Garnelo et al., 2018a; b), tasks are simply random-size subsets of random pixel locations 𝒙{\bm{x}} and values 𝒚{\bm{y}} from training set images. This random subsetting of training images into context and target sets transforms this into a meta-learning problem, and the “encoder” qϕ(z|𝒙,𝒚)q_{\phi}(z|{\bm{x}},{\bm{y}}) must learn to generalize over different context set sizes, with less posterior uncertainty as the context set size grows.

Neural processes

Our work builds on neural processes (NPs) (Garnelo et al., 2018a; b). NPs are deep neural network conditional generative models. Multiple variants of NPs have been proposed (Garnelo et al., 2018a; b; Kim et al., 2018), and careful empirical comparisons between them appear in the literature (Grover et al., 2019; Le et al., 2018).

NPs employ an alternative training objective to Eq. 2 arising from the fact that the graphical model in Fig. 2 allows a Bayesian update on the distribution of zz, conditioning on the entire context set to produce a posterior pθ(z|𝒙𝒞,𝒚𝒞)p_{\theta}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}). If the generative model is in a tractable family that allows analytic updates of this kind, then the NP objective corresponds to maximizing

𝔼𝒛qϕ(z|𝒙𝒯,𝒚𝒯)[logpθ(𝒚𝒯|z,𝒙𝒯)pθ(z|𝒙𝒞,𝒚𝒞)qϕ(z|𝒙𝒯,𝒚𝒯)]𝔼𝒛qϕ(z|𝒙𝒯,𝒚𝒯)[logpθ(𝒚𝒯|z,𝒙𝒯)qϕ(z|𝒙𝒞,𝒚𝒞)qϕ(z|𝒙𝒯,𝒚𝒯)]\mathbb{E}_{{\bm{z}}\sim q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}})}\left[\log{\textstyle\frac{p_{\theta}({\bm{y}}_{\mathcal{T}}|z,{\bm{x}}_{\mathcal{T}})p_{\theta}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})}{q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}})}}\right]\approx\mathbb{E}_{{\bm{z}}\sim q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}})}\left[\log{\textstyle\frac{p_{\theta}({\bm{y}}_{\mathcal{T}}|z,{\bm{x}}_{\mathcal{T}}){\color[rgb]{0,0,1}\definecolor[named]{pgfstrokecolor}{rgb}{0,0,1}q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})}}{q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}})}}\right] (4)

where replacing pθ(z|𝒙𝒞,𝒚𝒞)p_{\theta}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) with its variational approximation is typically necessary because most deep neural generative models have a computationally inaccessible posterior. This “NP objective” can be trained end-to-end, optimizing for both ϕ\phi and θ\theta simultaneously, where the split of training data into context and target sets must vary in terms of context set size. The choice of optimizing Eq. 4 instead of Eq. 2 is largely empirical (Le et al., 2018).

3 Network architecture

Refer to caption
(a) encoder
Refer to caption
(b) decoder
Figure 3: Our modified neural process architecture. The encoder produces a permutation invariant embedding that parameterizes a stochastic task encoding zz as follows: features extracted from each element of the context set using neural net hϕh_{\phi} are pooled, then passed to other neural networks ρϕ\rho_{\phi} and ηϕ\eta_{\phi} that control the distribution over task embedding zz. The decoder uses such a task encoding along with embeddings of target inputs to produce the output distribution for each target input.

The network architectures we employ build on NPs, inspired by our findings from Section 4. We describe them in detail in this section.

Encoder

The encoder qϕ(z|𝒙𝒞,𝒚𝒞)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) takes input observations from an i.i.d. model (see Fig. 2, plate over 𝒞{\mathcal{C}}), and therefore its encoding of those observations must be permutation invariant if it is to be learned efficiently. Our qϕq_{\phi}, as in related NP work, has a permutation-invariant architecture,

si=hϕ(xi,yi), 1in;s𝒞=i=1nsi;(μ𝒞,σ𝒞)=ρϕ(s𝒞);qϕ(z|𝒙𝒞,𝒚𝒞)=𝒩(μ𝒞,σ𝒞2).\displaystyle s_{i}=h_{\phi}(x_{i},y_{i}),\;1\leq i\leq n;\quad s_{\mathcal{C}}=\oplus_{i=1}^{n}s_{i};\quad(\mu_{\mathcal{C}},\sigma_{\mathcal{C}})=\rho_{\phi}(s_{\mathcal{C}});\quad q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})={\mathcal{N}}(\mu_{\mathcal{C}},\sigma_{{\mathcal{C}}}^{2})\;.

Here ρϕ\rho_{\phi} and hϕh_{\phi} are neural networks and \oplus is a permutation-invariant pooling operator. Fig. 3 contains diagrams of a generalization of this encoder architecture (see below). The standard NP architecture uses mean pooling; motivated by our findings in Section 4, we also employ max pooling.

Hierarchical Variational Inference

In order to achieve better calibrated uncertainty in small context size regimes, a more flexible approximate posterior should be beneficial. Consider the MNIST experiment shown in Fig. 6. Intuitively, an encoder could learn to map from the context set to a one-dimensional discrete zz value that lends support only to those digits that are compatible with the context pixel values at the given context pixel locations (𝒙𝒞,𝒚𝒞)({\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}). This suggests that qϕq_{\phi} should be flexible enough to produce a multimodal distribution over zz, which can be encouraged by making qϕq_{\phi} a mixture and corresponds to a hierarchical variational distribution (Ranganath et al., 2016; Yin & Zhou, 2018; Sobolev & Vetrov, 2019). Specifically, the encoder structure described above, augmented with a mixture variable is

qϕ(z|𝒙,𝒚)=qϕ(ψ|𝒙,𝒚)qϕ(z|ψ,𝒙,𝒚)𝑑ψ.q_{\phi}(z|{\bm{x}},{\bm{y}})=\int q_{\phi}(\psi|{\bm{x}},{\bm{y}})q_{\phi}(z|\psi,{\bm{x}},{\bm{y}})d\psi\;. (5)

This is shown in Fig. 3. For parameter-learning, semi-implicit variational inference (SIVI) (Yin & Zhou, 2018) constructs a tractable lower bound to the ELBO (See the Supplementary Material). Our experimental findings suggest that the combination of max pooling and SIVI produce state-of-the-art high-quality and diverse samples from well calibrated posteriors, as illustrated in Fig. 6.

Decoder

The deep neural network stochastic decoder in our work is standard and not a focus. Like other NP work, the data generating conditional likelihood in our decoder is assumed to factorize in a conditionally independent way, pθ(𝒚𝒯|z,𝒙𝒯)=i=1mpθ(yi|z,xi),p_{\theta}({\bm{y}}_{\mathcal{T}}|z,{\bm{x}}_{\mathcal{T}})=\prod_{i=1}^{m}p_{\theta}(y^{\prime}_{i}|z,x^{\prime}_{i}), where mm is the size of the target set and xix^{\prime}_{i} and yiy^{\prime}_{i} are a target set input and output respectively. Fig. 3(b) shows the decoder architecture, with the neural network gθg_{\theta} the link function to a per pixel likelihood.

4 Uncertainty in Neural Process models

Refer to caption
(a) Variational posterior entropy
Refer to caption
(b) Classifier prediction
Figure 4: Posterior contraction of qϕ(z|𝒙𝒞,𝒚𝒞)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) in a NP+max pooling model. (a) The entropy of qϕ(z|𝒙𝒞,𝒚𝒞)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) as a function of context set size, averaged over different tasks (images) and context sets. The gray shaded area in both plots indicates context set sizes that did not appear in the training data for the amortization artifact. (b) Predictions of a classifier trained to infer the context set size given only s𝒞s_{\mathcal{C}}, the pooled embedding of a context set. Equivalent results for the standard NP+mean pooling encoder and for ANP appear in the Supplementary Material.

In this section, we investigate how NP models handle uncertainty. A striking property of NP models is that as the size of the (random) context set increases, there is less sampling variation in target samples generated by passing zqϕ(z|𝒙𝒞,𝒚𝒞)z\sim q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) through the decoder. The samples shown in Fig. 1 are the likelihood mean (hence a deterministic function of zz), and so the reduced sampling variation can only be produced by decreased posterior uncertainty. Our experiments confirm this, as shown in Fig. 4(a): posterior uncertainty (as measured by entropy) decreases for increasing context size, even beyond the maximum training context size. Such posterior contraction is a well-studied property of classical Bayesian inference and is a consequence of the inductive bias of exchangeable models. However, NP models do not have the same inductive bias explicitly built in. How do trained NP models exhibit posterior contraction without being explicitly designed to do so? How do they learn to do so during training?

A simple hypothesis is that the network somehow transfers the context size through the pooling operation and into ρϕ(s𝒞)\rho_{\phi}(s_{\mathcal{C}}), which uses that information to set the posterior uncertainty. That hypothesis is supported by Fig. 4(b), which shows the results of training a classifier to infer the context size given only s𝒞s_{\mathcal{C}}. However, consider that within a randomly generated context set, some observations are more informative than others. For example, Fig. 5 shows the first {10,50,100}\{10,50,100\} pixels of an MNIST 2, greedily chosen to minimize DKL(qϕ(z|𝒙,𝒚)||qϕ(z|𝒙𝒞,𝒚𝒞))D_{\mathrm{KL}}(q_{\phi}(z|{\bm{x}},{\bm{y}})||q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})). If zz is interpreted to represent, amongst other things, which digit the image contains, then a small subset of pixels determine which digits are possible.

It is these highly informative pixels that drive posterior contraction in a trained NP. In a random context set, the number of highly informative pixels is random. For example, a max-pooled embedding saturates with the MM most highly informative context pixels, where MdM\leq d, the dimension of embedding space. On average, a random context set of size nn, taken from an image with NN pixels, will contain only nM/N\nicefrac{{nM}}{{N}} of the informative pixels. In truth, Fig. 4 displays how the information content of a context depends, on average, on the size of that context. Indeed, greedily choosing context pixels results in much faster contraction (Fig. 5).

Learning to contract

Posterior contraction is implicitly encouraged by the NP objective Eq. 4. It can be rewritten as

𝔼𝒛qϕ(z|𝒙𝒯,𝒚𝒯)[logpθ(𝒚𝒯|z,𝒙𝒯)]DKL(qϕ(z|𝒙𝒯,𝒚𝒯)||qϕ(z|𝒙𝒞,𝒚𝒞)).\displaystyle\mathbb{E}_{{\bm{z}}\sim q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}})}\left[\log p_{\theta}({\bm{y}}_{\mathcal{T}}|z,{\bm{x}}_{\mathcal{T}})\right]-D_{\mathrm{KL}}(q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}})||q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}))\;. (6)

The first term encourages perfect reconstruction of y𝒯y_{\mathcal{T}}, and discourages large variations in zqϕ(z|𝒙𝒯,𝒚𝒯)z\sim q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}}), which would result in large variations in predictive log-likelihood. This effect is stronger for larger target sets since there are more target pixels to predict. In practice, 𝒞𝒯{\mathcal{C}}\subset{\mathcal{T}}, so the first term also (indirectly) encourages posterior contraction for increasing context sizes. The second term, DKL(qϕ(z|𝒙𝒯,𝒚𝒯)||qϕ(z|𝒙𝒞,𝒚𝒞))D_{\mathrm{KL}}(q_{\phi}(z|{\bm{x}}_{\mathcal{T}},{\bm{y}}_{\mathcal{T}})||q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})), reinforces the contraction by encouraging the context posterior to be close to the target posterior.

Refer to caption Refer to caption
Figure 5: (Left) The first {10,50,100}\{10,50,100\} pixels greedily chosen to minimize DKL(qϕ(z|𝒙,𝒚)||qϕ(z|𝒙𝒞,𝒚𝒞))D_{\mathrm{KL}}(q_{\phi}(z|{\bm{x}},{\bm{y}})||q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})). These pixels are highly informative about zz, but only a subset of them will appear the vast majority of random context sets. (Right) Posterior entropy decreasing as context size increases, for different methods of generating a context set: green is the average over 100 random context sets of each size; blue greedily chooses context pixels to minimize posterior entropy; and orange greedily minimizes DKL(qϕ(z|𝒙,𝒚)||qϕ(z|𝒙𝒞,𝒚𝒞))D_{\mathrm{KL}}(q_{\phi}(z|{\bm{x}},{\bm{y}})||q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})). The black dashed line represents the posterior entropy when conditioned on the full image.

Although the objective encourages posterior contraction, the network mechanisms for achieving contraction are not immediately clear. Ultimately, the details depend on interplay between the pixel embedding function, hϕh_{\phi}, the pooling operation \oplus, and ρϕ\rho_{\phi}. We focus on mean and max pooling.

Max pooling

As the size of the context set increases, the max-pooled embedding s𝒞=i=1nsis_{{\mathcal{C}}}=\oplus_{i=1}^{n}s_{i} is non-decreasing in nn; in a trained NP model, s𝒞||s_{{\mathcal{C}}}|| will increase each time an informative pixel is added to the context set; it will continue increasing until the context embedding saturates at the full image embedding. At a high level, this property of max-pooling means that the σ𝒞\sigma_{\mathcal{C}} component of ρϕ(s𝒞)\rho_{\phi}(s_{\mathcal{C}}) has a relatively simple task: represent a function such that the posterior entropy is a decreasing function of all dimensions of the embedding space. An empirical demonstration that ρϕ\rho_{\phi} achieves this can be found in the Supplementary Material.

Mean pooling

For a fixed image, as the size of a random context set increases, its mean-pooled embedding will, on average, become closer to the full image embedding. Moreover, the mean-pooled embeddings of all possible context sets of the image are contained in the convex set whose hull is formed by (a subset of) the individual pixel embeddings. The σ𝒞\sigma_{\mathcal{C}} component of ρϕ(s𝒞)\rho_{\phi}(s_{\mathcal{C}}), then, must approximate a function such that the posterior entropy is a convex function on the convex set formed by individual pixel embeddings, with minimum at or near the full image embedding. Learning such a function across the embeddings of many training images seems a much harder learning task than that required by max pooling, which may explain the better performance of max pooling relative to mean pooling in NPs (see Section 5).

Generalizing posterior contraction

Remarkably, trained NP-based models generalize their posterior contraction to context and target sizes not seen during training (see Fig. 4). The discussion of posterior contraction in NPs using mean and max pooling in the previous paragraphs highlights a shared property: for both models, the pooled embeddings of all possible context sets that can be obtained from an image are in a convex set that is determined by a subset of possible context set embeddings. For max-pooling, the convex set is formed by the max-pooled embedding of the MM “activation” pixels. For mean-pooling, the convex set is obtained from the convex hull of the individual pixel embeddings. Furthermore, the full image embedding in both cases is contained in the convex set. We conjecture that a sufficient condition for an NP image completion model to yield posterior contraction that generalizes to context sets of unseen size is as follows: For any image, the pooled embedding of every possible context set (which includes the full image) lies in a convex subset of the embedding space.

5 Experimental evaluation

Refer to caption
(a) NP objective with average pooling
Refer to caption
(b) NP objective with average pooling
Refer to caption
(c) ANP
Refer to caption
(d) ANP
Refer to caption
(e) NP+SIVI objective with max pooling
Refer to caption
(f) NP+SIVI objective with max pooling
Figure 6: Example MNIST and CelebA image completion tasks, for each of three NP methods. The following guide applies to each block. The top row shows context sets of different sizes (context sets are exactly the same for all methods), i.e., one task per column. The ground truth image is in the upper right corner. The rows correspond to the mean function produced by gθg_{\theta} for different sampled values of zz. The bottom row shows an empirical estimate of the standard deviation of the mean function from 1000 draws of zz, a direct visualization of the uncertainty encoding.

We follow the experimental setup of Garnelo et al. (2018b), where images are interpreted as functions that map pixel locations to color values, and image in-painting is framed as an amortized predictive inference task where the latent image-specific regression function needs to be inferred from a small context set of provided pixel values and locations. For ease of comparison to prior work, we use the same MNIST (LeCun et al., 1998) and CelebA (Liu et al., 2015) datasets. Specific architecture details for all networks are provided in the Supplementary Materials and open-source code for all experiments will be released at the time of publication.

Qualitative Results

Fig. 6 shows qualitative image in-painting results for MNIST and CelebA images. It is apparent in both contexts that ANPs perform poorly when the context set is small, despite the superior sharpness of their reconstructions when given large context sets. The sets of digits and faces that ANPs produce are not sharp, realistic, nor diverse. On the other hand, their predecessor, NP (with mean pooling), arguably exhibits more diversity but suffers at all context sizes in terms of realism of the images. Our NP+SIVI with max pooling approach produces results with two important characteristics: 1) the images generated with a small amount of contextual information are sharper and more realistic; and 2) there is high context-set-compatible variability across the i.i.d. samples. These qualitative results demonstrate that max pooling plus the SIVI objective result in posterior mean functions that are sharper and more appropriately diverse, except in the high context set size regime where diversity does not matter and ANP produces much sharper images. Space limitations prohibit showing large collections of samples where the qualitative differences are even more readily apparent. The Supplementary Material contains more comprehensive examples.

Table 1: Predictive held-out test log-likelihood
Method MNIST CelebA
NP+mean 0.96±0.120.96\pm 0.12 2.91±0.302.91\pm 0.30
ANP+mean 0.55±0.120.55\pm 0.12 1.81±0.181.81\pm 0.18
Method MNIST CelebA
NP+max 1.07±0.111.07\pm 0.11 3.17±0.303.17\pm 0.30
SIVI+max 0.99±0.250.99\pm 0.25 2.99±0.392.99\pm 0.39
Quantitative Results

Quantitatively assessing posterior predictive calibration is an open problem (Salimans et al., 2016; Heusel et al., 2017). Table 1 reports, for the different architectures we consider, predictive held out test-data log-likelihoods averaged over 10,000 MNIST and 19,962 CelebA test images respectively. While the reported results make it clear that max pooling improves held-out test likelihood, likelihood alone does not provide a direct measure of sample quality nor diversity. It simply measures how much mass is put on each ground-truth completion.

Refer to caption
Figure 7: Inception scores of conditional samples (left, MNIST; right CelebA).

Borrowing from the generative adversarial networks community, who have faced the similar problems of how to quantitatively evaluate models via examination of the samples they generate, we compute inception scores (Salimans et al., 2016) using conditionally generated samples for different context set sizes for all of the considered NP architectures and report them in Fig. 7. However, since inception scores are based on classification outputs of inception network (Szegedy et al., 2016), an ImageNet (Deng et al., 2009) classifier, it is known to give misleading results when applied to other image domains (Barratt & Sharma, 2018) including MNIST and CelebA. We therefore use trained MNIST and CelebA classifiers (He et al., 2016) in place of inception network. (See Supplementary Materials for details.) The images used to create the results in Fig. 7 are the same as in Fig. 6 and the sequence of context sets considered include the ones in Fig. 6. For each context set size, the reported inception scores are aggregated over 10 different randomly chosen context sets. The dark gray dashed lines are the inception scores of training samples and represent the maximum one might hope to achieve at a context set size of zero (these plots start at one).

For small context sets, an optimally calibrated model should have high uncertainty and therefore generate samples with high diversity, resulting in high inception scores as observed. As the context set grows, sample diversity should be reduced, resulting in lower scores. Here again, architectures using max pooling produce large gains in inception score in low-context size settings. Whether the addition of SIVI is helpful is less clear here. Nonetheless, the inception score is again only correlated with the qualitative gains we observe in Fig. 6.

6 Conclusion

The contributions we report in this paper include suggested neural process architectures (max pooling, no deterministic path) and objectives (regular amortized inference versus the heuristic NP objective, SIVI versus non-mixture variational family) that produce qualitatively better calibrated posteriors, particularly in low context cardinality settings. We provide empirical evidence of how natural posterior contraction may be facilitated by the neural process architecture. Finally, we establish quantitative evidence that shows improvements in neural process posterior predictive performance and highlight the need for better metrics for quantitatively evaluating posterior calibration.

We remind the reader that this work, like most other deep learning work, highlights the impact of varying only a small subset of the dimensions of architecture and objective degrees of freedom. We found that, for instance, simply making ρϕ\rho_{\phi} deeper than that reported in the literature improved baseline results substantially. The choice of learning rate also had a large impact on the relative gap between the reported alternatives. We report what we believe to be the most robust configuration across all the configurations that we explored: max pooling and SIVI consistently improve performance.

Acknowledgments

SN, KC and FW are supported by Support for Teams to Advance Interdisciplinary Research (STAIR) grant. SN and FW additionally acknowledge the support of the Natural Sciences and Engineering Research Council of Canada (NSERC), the Canada CIFAR AI Chairs Program, and the Intel Parallel Computing Centers program. This material is based upon work supported by the United States Air Force Research Laboratory (AFRL) under the Defense Advanced Research Projects Agency (DARPA) Data Driven Discovery Models (D3M) program (Contract No. FA8750-19-2-0222) and Learning with Less Labels (LwLL) program (Contract No.FA8750-19-C-0515). Additional support was provided by UBC’s Composites Research Network (CRN), Data Science Institute (DSI) grants. BBR acknowledges the support of NSERC. This research was enabled in part by technical support and computational resources provided by WestGrid (https://www.westgrid.ca/) and Compute Canada (www.computecanada.ca).

References

  • Barratt & Sharma (2018) Shane Barratt and Rishi Sharma. A note on the inception score, 2018.
  • Burda et al. (2016) Yuri Burda, Roger Grosse, and Ruslan Salakhutdinov. Importance weighted autoencoders. In ICLR, 2016.
  • Deng et al. (2009) J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In CVPR09, 2009.
  • Garnelo et al. (2018a) Marta Garnelo, Dan Rosenbaum, Christopher Maddison, Tiago Ramalho, David Saxton, Murray Shanahan, Yee Whye Teh, Danilo Rezende, and SM Ali Eslami. Conditional neural processes. In International Conference on Machine Learning, pp. 1704–1713, 2018a.
  • Garnelo et al. (2018b) Marta Garnelo, Jonathan Schwarz, Dan Rosenbaum, Fabio Viola, Danilo J Rezende, SM Eslami, and Yee Whye Teh. Neural processes. arXiv preprint arXiv:1807.01622, 2018b.
  • Gershman & Goodman (2014) Samuel Gershman and Noah Goodman. Amortized inference in probabilistic reasoning. In Proceedings of the annual meeting of the Cognitive Science Society, volume 36, 2014.
  • Gordon et al. (2019) Jonathan Gordon, John Bronskill, Matthias Bauer, Sebastian Nowozin, and Richard Turner. Meta-learning probabilistic inference for prediction. In International Conference on Learning Representations, 2019.
  • Grover et al. (2019) Aditya Grover, Dustin Tran, Rui Shu, Ben Poole, and Kevin Murphy. Probing uncertainty estimates of neural processes. 2019.
  • He et al. (2016) Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp.  770–778, 2016.
  • Heusel et al. (2017) Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In Advances in neural information processing systems, pp. 6626–6637, 2017.
  • Hinton (2007) Geoffrey E Hinton. To recognize shapes, first learn to generate images. Progress in brain research, 165:535–547, 2007.
  • Kim et al. (2018) Hyunjik Kim, Andriy Mnih, Jonathan Schwarz, Marta Garnelo, Ali Eslami, Dan Rosenbaum, Oriol Vinyals, and Yee Whye Teh. Attentive neural processes. In International Conference on Learning Representations, 2018.
  • Kingma & Welling (2014) Diederik P Kingma and Max Welling. Auto-encoding variational Bayes. In ICLR, 2014.
  • Le et al. (2018) Tuan Anh Le, Hyunjik Kim, Marta Garnelo, Dan Rosenbaum, Jonathan Schwarz, and Yee Whye Teh. Empirical evaluation of neural process objectives. In NeurIPS workshop on Bayesian Deep Learning, 2018.
  • LeCun et al. (1998) Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
  • Liu et al. (2015) Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of the IEEE international conference on computer vision, pp.  3730–3738, 2015.
  • Ranganath et al. (2016) Rajesh Ranganath, Dustin Tran, and David Blei. Hierarchical variational models. In International Conference on Machine Learning, pp. 324–333, 2016.
  • Rasmussen (2003) Carl Edward Rasmussen. Gaussian processes in machine learning. In Summer School on Machine Learning, pp.  63–71. Springer, 2003.
  • Salimans et al. (2016) Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. In Advances in neural information processing systems, pp. 2234–2242, 2016.
  • Sobolev & Vetrov (2019) Artem Sobolev and Dmitry P Vetrov. Importance weighted hierarchical variational inference. In Advances in Neural Information Processing Systems, pp. 603–615, 2019.
  • Szegedy et al. (2016) Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp.  2818–2826, 2016.
  • Yin & Zhou (2018) Mingzhang Yin and Mingyuan Zhou. Semi-implicit variational inference. arXiv preprint arXiv:1805.11183, 2018.

Appendix A Image inpainting results

Fig. 8 shows the inpainting results from different methods when the context set is carried to the output. In other words, inference is done via Equation 1 when the target and context sets are disjoint and the given 𝒚𝒞{\bm{y}}_{\mathcal{C}} is directly copied to the shown output, instead of asking the model to predict values of 𝒚𝒞{\bm{y}}_{\mathcal{C}}.

Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Figure 8: Image inpainting results when the context set is directly copied to the shown output and the model is queried for the rest of image pixels. From left to right, NP, ANP, and ours (NP+SIVI+max pooling). As non-attentive models are known to underfit on the context points, the final results for them are not smooth. ANP improves on this aspect.

Appendix B Architecture and training details

B.1 Architecture

In the following, dz=ds=dh=512d_{z}=d_{s}=d_{h}=512 and dψ=32d_{\psi}=32.

Encoder

The embedding function for each input/output pair is

hϕ(xi,yi):(dx+dy)fc+reludhfc+reludhfcds.h_{\phi}(x_{i},y_{i}):(d_{x}+d_{y})\xrightarrow{\text{fc+relu}}d_{h}\xrightarrow{\text{fc+relu}}d_{h}\xrightarrow{\text{fc}}d_{s}\;.

For SIVI models, the rest of the encoder ρϕ\rho_{\phi} and ηϕ\eta_{\phi} is defined as

ρϕ(s)\displaystyle\rho_{\phi}(s) :(ds+dϵ)fc+reludhfcdψ\displaystyle:(d_{s}+d_{\epsilon})\xrightarrow{\text{fc+relu}}d_{h}\xrightarrow{\text{fc}}d_{\psi}
ηϕ(s,ψ)\displaystyle\eta_{\phi}(s,\psi) :(ds+dψ)fc+reludhfc2dz\displaystyle:(d_{s}+d_{\psi})\xrightarrow{\text{fc+relu}}d_{h}\xrightarrow{\text{fc}}2*d_{z}

where ϵ𝒩(0,I)\epsilon\sim\mathcal{N}(0,I) and ϵdϵ\epsilon\in\mathbb{R}^{d_{\epsilon}}. The output of ηϕ\eta_{\phi} is then split into two dzd_{z}-dimensional vectors μz\mu_{z} and σz\sigma^{\prime}_{z} with

qϕ(z|𝒙𝒞,𝒚𝒞)=𝒩(μz,diag(0.9+0.1sigmoid(σz))2).q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})=\mathcal{N}(\mu_{z},\text{diag}(0.9+0.1*\texttt{sigmoid}(\sigma^{\prime}_{z}))^{2})\;.

For the NP models, there is no ηϕ\eta_{\phi}, and ρϕ\rho_{\phi} is defined as

ρϕ(s):dsfc+reludhfc2dz\rho_{\phi}(s):d_{s}\xrightarrow{\text{fc+relu}}d_{h}\xrightarrow{\text{fc}}2*d_{z}

where the output is split into two vectors dzd_{z}-dimensional vectors like in SIVI.

Decoder

gθ(xj,z):dx+dzfc+reludh4 timesfc2dyg_{\theta}(x^{\prime}_{j},z):d_{x}+d_{z}\underbrace{\xrightarrow{\text{fc+relu}}d_{h}}_{\text{4 times}}\xrightarrow{\text{fc}}2*d_{y}, where the output is split into two dyd_{y}-dimensional vectors μy\mu_{y} and σy\sigma^{\prime}_{y}, and

q(yj|xj,z)=𝒩(μy,diag(0.9+0.1softplus(σy))2).q(y^{\prime}_{j}|x^{\prime}_{j},z)=\mathcal{N}(\mu_{y},\text{diag}(0.9+0.1*\texttt{softplus}(\sigma^{\prime}_{y}))^{2})\;.

For the models with a fixed observation variance, the output of gθg_{\theta} is only the vector μy\mu_{y} and q(yj|xj,z)=𝒩(μy,0.22𝑰dy)q(y^{\prime}_{j}|x^{\prime}_{j},z)=\mathcal{N}(\mu_{y},0.2^{2}*{\bm{I}}_{d_{y}}).

ANP model is implemented with the same specifications as above and the other components (deterministic path and attention) is the same as Kim et al. (2018).

B.2 Training

All the models were trained using Adam optimizer and a batch size of 16 for 100 epochs. Learning rate was 5×1045\times 10^{-4} for NP+avg, NP+max and SIVI+max, and 5×1055\times 10^{-5} for ANP. For SIVI on MNIST, a learning rate scheduler was employed as well that would multiply the learning rate by 0.10.1 after 20, 50 and 80 epochs.

The procedure for constructing context sets and target sets from a chosen image in the dataset was as follows. From the image, n+mn+m^{\prime} pixels, where n[1,200)n\sim[1,200) and m[0,200)m^{\prime}\sim[0,200), were chosen without replacement. The first nn pixels constitute the context set, and all m=n+mm=n+m^{\prime} pixels were put into the target set.

B.3 SIVI objective

As stated in the paper, SIVI bound is a tractable lower bound to the ELBO for hierarchical variational families (c.f. Eq. 5). This bound in the context of Neural Processes is defined as

𝔼qϕ(z,ψ0|𝒙,𝒚)[𝔼qϕ(ψ1:K|𝒙,𝒚)[logpθ(𝒚|z,𝒙)pθ(z)1K+1k=0Kqϕ(z|𝒙,ψk)]]ELBOlogpθ(𝒚|𝒙)\mathbb{E}_{q_{\phi}(z,\psi_{0}|{\bm{x}},{\bm{y}})}\left[\mathbb{E}_{q_{\phi}(\psi_{1:K}|{\bm{x}},{\bm{y}})}\left[\log\frac{p_{\theta}({\bm{y}}|z,{\bm{x}})p_{\theta}(z)}{\frac{1}{K+1}\sum_{k=0}^{K}q_{\phi}(z|{\bm{x}},\psi_{k})}\right]\right]\leq\text{ELBO}\leq\log p_{\theta}({\bm{y}}|{\bm{x}}) (7)

where qϕ(ψ1:K|𝒙)=i=1Kqϕ(ψi|𝒙)q_{\phi}(\psi_{1:K}|{\bm{x}})=\prod_{i=1}^{K}q_{\phi}(\psi_{i}|{\bm{x}}) and ELBO is defined as Eq. 2.

Appendix C Other variants of Neural Process models

There are many variants of Neural Processes with different probabilistic modelling assumptions and network architectures. We have attempted to be as clear and fair as possible in generating the qualitative results in the main text. In this section we clarify which specific architectures were considered and why. Moreover, to make the results comparable with other publications in the literature, we include qualitative results for other popular architecture choices not considered in the main text.

ANPs (Kim et al., 2018) include a deterministic path bypassing zz from the encoder to the decoder that is not found in the original NP (Garnelo et al., 2018b). Our implementation of NP follows the original model without a deterministic path. In Kim et al. (2018), a NP without attention but with a deterministic path was considered. Fig. 9 shows that adding a deterministic path to NP generally hurts sample diversity in small context sizes. An additional complicating factor is whether gθg_{\theta} produces just the mean or both the mean and the variance of the likelihood function. In line with previous results (Le et al., 2018), we found that if gθg_{\theta} is trained to produce the observation variance of pθ(yi|z,xi)p_{\theta}(y^{\prime}_{i}|z,x^{\prime}_{i}), then models with a deterministic path (including ANP) tend to end up with a large observation variance and a low-variance task-embedding posterior qϕ(z|𝒙𝒞,𝒚𝒞)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}), leading to poorly calibrated uncertainty and low sample diversity. Therefore, to be as fair as possible to ANP models, its results in the main text correspond to a model trained with a fixed observation variance, whereas NP and NP+SIVI results are reported with learned observation variance. Fig. 10 shows the results for ANP with learned observation variance.

Refer to caption
(a) Fixed observation variance
Refer to caption
(b) Learned observation variance
Refer to caption
(c) Fixed observation variance
Refer to caption
(d) Learned observation variance
Figure 9: Qualitative results of NP+avg with deterministic path on (top) MNIST and (bottom) CelebA datasets. These plots show poor sample diversity from the model irrespective of whether the observation variance is fixed or learned.
Refer to caption
(a) MNIST
Refer to caption
(b) CelebA
Figure 10: Qualitative results of ANP model with learned observation variance. Comparing (10(a)) with Fig. 6(c) shows that learning the observation variance hurts sample diversity. It is not as easy to compare sample diversity for CelebA (see (10(b)) and Fig. 6(d)). However, ANP in general performs worse than SIVI+max or NP+max on small context sets.

Appendix D Fig. 4 Experimental Details

Refer to caption
(a) Variational posterior entropy
Refer to caption
(b) Classifier prediction
Figure 11: Posterior contraction of qϕ(z|𝒙𝒞,𝒚𝒞)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) in a NP+mean pooling model.

Fig. 4(a) shows entropy of the variational posterior, i.e., qϕ(z|𝒙𝒞,𝒚𝒞)q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}), versus context set size (nn) for a growing context set with i.i.d. items. The plot shows an aggregation over 1000 runs of this procedure, each with a different ground truth image. The experiment verifies that the learned NP posterior follows the classical Bayesian inference results and, more interestingly, the posterior contraction even generalizes to context sets larger than the context sets seen during training. The plot was generated by an NP+max model trained on MNIST, but the observed behavior is not specific to it. We see the same behavior when average pooling is used for the CelebA dataset.

The experiment suggests that even though the context dataset is represented through an aggregated embedding that does not explicitly embed nn, the training objective forces the networks and the embedding space to retain information about nn. We validate this by training a classifier to predict nn given the learned embeddings s𝒞s_{\mathcal{C}}. Fig. 4(b) shows the classifier performance on a held-out test set and shows a strong correlation between embeddings s𝒞s_{\mathcal{C}} and context set sizes.

Fig. 11 shows the same behavior with mean pooling. The plot is generated by a NP+mean model trained on MNIST dataset.

Appendix E Max pooled embeddings and posterior entropy

As discussed in the main text, a NP model with max pooling exhibits posterior contraction by learning a ρϕ\rho_{\phi} such that the posterior entropy is a decreasing function in all dimensions of embedding space. To illustrate, Fig. 12 shows s𝒞1||s_{\mathcal{C}}||_{1} vs context size (increasing), and the posterior entropy versus s𝒞1||s_{\mathcal{C}}||_{1} (decreasing).

Refer to caption
(a)
Refer to caption
(b)
Figure 12: (a) Norm of pooled embedding, s𝒞1||s_{\mathcal{C}}||_{1}, versus context size for three different methods of context set generation. Note that the embeddings are shifted so that the minimum embedding value in each dimension is 0. (b) Posterior entropy versus norm of (shifted) pooled embedding. Observe that the norm of the embedding is strictly increasing in context size, with large increases when the context is small; and that the posterior entropy is decreasing as a function of the norm of the embedding.

Appendix F Computing Test Data Log Likelihoods

The test data (normalized) log likelihoods 1|𝒯|logpθ(𝒚𝒯|𝒙𝒯,𝒙𝒞,𝒚𝒞)\frac{1}{|{\mathcal{T}}|}\log p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) are computed and averaged over context/target sets sampled from held-out test sets. Context sets and target sets are disjoint (i.e., all the items in target set are unobserved) and have a random size in [1,200)[1,200). As we do not have a closed form for predictive log-likelihoods, we compute the following IWAE-like lower bound (Burda et al., 2016) instead with K=1000.

logpθ(𝒚𝒯|𝒙𝒯,𝒙𝒞,𝒚𝒞)\displaystyle\log p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}}) 𝔼qϕ(z1:K|𝒙𝒞,𝒚𝒞)log1Kk=1Kpθ(𝒚𝒯|𝒙𝒯,z)pθ(z|𝒙𝒞,𝒚𝒞)qϕ(zk|𝒙𝒞,𝒚𝒞)\displaystyle\geq\mathbb{E}_{q_{\phi}(z_{1:K}|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})}\log\frac{1}{K}\sum_{k=1}^{K}\frac{p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},z)p_{\theta}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})}{q_{\phi}(z_{k}|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})} (8)
𝔼qϕ(z1:K|𝒙𝒞,𝒚𝒞)log1Kk=1Kpθ(𝒚𝒯|𝒙𝒯,zk)qϕ(z|𝒙𝒞,𝒚𝒞)qϕ(zk|𝒙𝒞,𝒚𝒞)\displaystyle\approx\mathbb{E}_{q_{\phi}(z_{1:K}|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})}\log\frac{1}{K}\sum_{k=1}^{K}\frac{p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},z_{k})q_{\phi}(z|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})}{q_{\phi}(z_{k}|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})} (9)
=𝔼qϕ(z1:K|𝒙𝒞,𝒚𝒞)log1Kk=1Kpθ(𝒚𝒯|𝒙𝒯,zk).\displaystyle=\mathbb{E}_{q_{\phi}(z_{1:K}|{\bm{x}}_{\mathcal{C}},{\bm{y}}_{\mathcal{C}})}\log\frac{1}{K}\sum_{k=1}^{K}p_{\theta}({\bm{y}}_{\mathcal{T}}|{\bm{x}}_{\mathcal{T}},z_{k})\;. (10)

Appendix G Computing Inception Scores in our experiments

G.1 Definition

Inception score is defined in a way such that a high score requires the individual samples to be classifiable with high confidence and, at the same time, the marginal class distribution of samples to be diverse. More formally,

logIS=𝔼𝒙G[DKL(p(y|𝒙)||p(y))]=𝔼𝒙G[H(p(y|𝒙))H(p(y|𝒙),p(y))]\log\text{IS}=\mathbb{E}_{{\bm{x}}\sim G}\left[D_{\mathrm{KL}}(p(y|{\bm{x}})||p(y))\right]=-\mathbb{E}_{{\bm{x}}\sim G}\left[H(p(y|{\bm{x}}))-H(p(y|{\bm{x}}),p(y))\right] (11)

where GG is a generator producing samples 𝒙{\bm{x}} and yy is the classification labels specified by the classifier.

G.2 Classifier networks

As results in the GAN literature suggest that inception score is unreliable when applied to image domains other than ImageNet, we replace inception network with classifiers trained on MNIST and CelebA datasets. The network architecture of both classifiers is ResNet (He et al., 2016). The MNIST classifier network is trained to solve the MNIST digit classification task with 10 classes. It is more challenging for CelebA as there is no well-defined set of labelled classes for it. As CelebA images are labelled with 40 attributes, we choose the four attributes of {Male, Black Hair, Smiling, Young} and construct a synthetic classification task with 242^{4} classes where each class refers to a configuration of the chosen attributes. The trained models are used in place of inception network to get calibrated scores in our experiments.

Appendix H MNIST classifier results

We examine the diversity of samples generated from each model by classifying them using a MNIST classifier and looking at the distribution of the predictions. The main expectations are that (1) the models have a non-zero probability of generating the ground truth image irrespective of the context set and that (2) the models do not generate digits that are inconsistent with the context set.

As the true posterior probability of the digit given a few pixels of its image (the context set) is unknown, we report Figs. 13 and 14 as a proxy to it. These figures show the results of an experiment where a sequence of growing context sets incrementally reveals an image of a 3 and compare the prediction distribution of generated samples from different models. The final image in Fig. 13 is chosen from the test set, and the context sets are constructed to eliminate a specific digit with each step. In Fig. 14, the final image is synthetic and hand-drawn. The context set in each step is grown by adding new strokes of the digit.

Refer to caption
Figure 13: MNIST classification results for a sequence of growing context sets. Each column shows the results for the context set in the first row. Each histogram under a context set shows the prediction distribution of a MNIST classifier for 1000 samples from a model that was conditioned on the context set. The context set sizes are written at the top of each column. The first context set is the top left pixel, treated as an uninformative context set. Each of the following context sets add 10 new pixels that are specifically chosen to eliminate a remaining possible digit (in the order of 0 to 9). Given the digit to eliminate, the 10 chosen pixels are the ones that differ the most in pixel intensity between the mean image of all instances of 3 in the training set and the mean image of all instances of the digit to eliminate.
Refer to caption
Figure 14: MNIST classification results for a synthetic sequence of context sets. The context sets are designed to hint at an image of a 3. The details of how the subplots are organized is the same as Fig. 13. All the models except NP+avg have a non-zero probability for the correct digit throughout the process. In terms of the compatibility of the generated digits with the context set, ANP works reasonably well on larger context sets while NP+max and SIVI+max generally outperform the others throughout the process.

Appendix I Additional Qualitative Results

In this section, we report additional results for MNIST and CelebA experiments. Figs. 15 and 17 show 15 samples per context set drawn from models trained on the MNIST dataset, and Figs. 16 and 18 show the same for the CelebA dataset.

Refer to caption
(a) NP objective with average pooling
Refer to caption
(b) NP objective with max pooling
Refer to caption
(c) NP+SIVI objective with max pooling
Refer to caption
(d) ANP
Figure 15: Samples from models trained on the MNIST dataset.
Refer to caption
(a) NP objective with average pooling
Refer to caption
(b) NP objective with max pooling
Refer to caption
(c) NP+SIVI objective with max pooling
Refer to caption
(d) ANP
Figure 16: Samples from models trained on the CelebA dataset.
Refer to caption
(a) NP objective with average pooling
Refer to caption
(b) NP objective with max pooling
Refer to caption
(c) NP+SIVI objective with max pooling
Refer to caption
(d) ANP
Figure 17: Samples from models trained on the MNIST dataset.
Refer to caption
(a) NP objective with average pooling
Refer to caption
(b) NP objective with max pooling
Refer to caption
(c) NP+SIVI objective with max pooling
Refer to caption
(d) ANP
Figure 18: Samples from models trained on the CelebA dataset.