Papers
Topics
Authors
Recent
Search
2000 character limit reached

Patch Attentive Neural Processes (PANP)

Updated 1 March 2026
  • The paper introduces PANP, which uses patch representations to reduce attention complexity from O(N²) to O(P²) for scalable high-resolution image processing.
  • It employs dual paths – deterministic and latent – via Transformer encoders to capture both context-specific and global generative features.
  • Empirical evaluations on datasets like CIFAR-10 and CelebA demonstrate improved MSE and reconstruction quality, confirming PANP’s efficacy in high-res meta-regression.

Patch Attentive Neural Processes (PANP) extend the Attentive Neural Process (ANP) architecture to high-resolution image meta-regression by introducing learnable patch representations and scalable Transformer-based attention mechanisms. PANP applies a patchwise processing approach inspired by Vision Transformer (ViT) and Masked Auto-Encoder (MAE), allowing Neural Process (NP) models to handle large images by substantially reducing attention sequence length, while maintaining flexible deterministic and latent modeling pathways (Yu et al., 2022).

1. Problem Setting and Motivation

PANP addresses meta-learning regression, in which each task involves reconstructing a sample from a distribution of two-dimensional functions f:R2Rf: \mathbb{R}^2 \to \mathbb{R}, often modeled as image regression under a random function family such as a Gaussian process with a fixed kernel. Given a context set of observed input-output pairs (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C} and target inputs XT={xt}tTX_T = \{ x_t \}_{t \in T}, the objective is to predict target outputs YT={yt}tTY_T = \{ y_t \}_{t \in T}.

Standard Neural Process models aggregate information by mean pooling, which limits expressiveness, while ANP augments this with multi-head attention over the context set to allow target-specific conditioning. However, ANP’s cross-attention step incurs O(N2)O(N^2) time and space complexity, where NN is the number of context tokens. For images, NN can easily exceed 10510^5 for moderate resolutions, making attention intractable at the per-pixel level. PANP addresses this limitation by partitioning the image into PNP \ll N non-overlapping square patches and processing these as the basic tokens, making cross-attention tractable even for high-dimensional image inputs.

2. Model Architecture

The PANP architecture consists of two parallel processing paths (deterministic and latent), each based on attention over patch representations.

2.1 Patch Extraction and Encoding

An image IRH×W×CI \in \mathbb{R}^{H \times W \times C} is divided into (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}0 square patches (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}1, each of size (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}2. Each patch (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}3 is encoded by a shared convolutional encoder (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}4 to produce an embedding (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}5. After adding a trainable positional embedding (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}6 to (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}7, one obtains the initial patch token (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}8.

2.2 Deterministic Path

A stack of (XC,YC)={(xc,yc)}cC(X_C, Y_C) = \{ (x_c, y_c) \}_{c \in C}9 Transformer encoder blocks processes the set of context patch tokens, with each token updated via multi-headed self-attention (MSA) and layer normalization (LN):

XT={xt}tTX_T = \{ x_t \}_{t \in T}0

After XT={xt}tTX_T = \{ x_t \}_{t \in T}1 layers, XT={xt}tTX_T = \{ x_t \}_{t \in T}2 for XT={xt}tTX_T = \{ x_t \}_{t \in T}3. These are mean-pooled to form a global context summary XT={xt}tTX_T = \{ x_t \}_{t \in T}4.

For each target patch XT={xt}tTX_T = \{ x_t \}_{t \in T}5, a query token XT={xt}tTX_T = \{ x_t \}_{t \in T}6 is constructed and used in a cross-attention operation against the set XT={xt}tTX_T = \{ x_t \}_{t \in T}7:

XT={xt}tTX_T = \{ x_t \}_{t \in T}8

2.3 Latent Path

The latent path employs a (shared or separate) Transformer encoder stack to yield patchwise representations XT={xt}tTX_T = \{ x_t \}_{t \in T}9 for YT={yt}tTY_T = \{ y_t \}_{t \in T}0. These are mean-pooled:

YT={yt}tTY_T = \{ y_t \}_{t \in T}1

A variational Gaussian posterior over a global latent YT={yt}tTY_T = \{ y_t \}_{t \in T}2 is parameterized as:

YT={yt}tTY_T = \{ y_t \}_{t \in T}3

At training time, a mean-pooled feature over YT={yt}tTY_T = \{ y_t \}_{t \in T}4, YT={yt}tTY_T = \{ y_t \}_{t \in T}5, is used to estimate the "true" posterior YT={yt}tTY_T = \{ y_t \}_{t \in T}6.

2.4 Decoder

A multilayer perceptron (MLP) with GeLU activations decodes each target patch:

YT={yt}tTY_T = \{ y_t \}_{t \in T}7

where YT={yt}tTY_T = \{ y_t \}_{t \in T}8 denotes concatenation. The reconstructions YT={yt}tTY_T = \{ y_t \}_{t \in T}9 are reassembled to form the target output.

3. Mathematical Formulation and Learning Objective

The PANP objective follows the standard NP framework with modifications for patch-based representations:

  • For patch encodings, O(N2)O(N^2)0, O(N2)O(N^2)1.
  • For each target O(N2)O(N^2)2, cross-attend to context representations as above.
  • The decoder predicts a likelihood per patch conditioned on the sampled latent and attended context:

O(N2)O(N^2)3

The evidence lower bound (ELBO) per task is:

O(N2)O(N^2)4

This structure retains both global stochasticity via the latent O(N2)O(N^2)5 and context-specific adaptation through cross-attentive deterministic paths.

4. Computational Complexity and Scalability

A key innovation in PANP is the reduction in attention bottleneck by substituting O(N2)O(N^2)6pixels with O(N2)O(N^2)7. With typical patch width O(N2)O(N^2)8 in the range 8–16, O(N2)O(N^2)9 is smaller by multiple orders of magnitude than the pixel count, reducing attention cost from NN0 in ANP to NN1 in PANP. Mean aggregation, as in NPs, remains NN2, but attention is tractable for large images only when working with patch-level tokens—ANP is not feasible for images beyond NN3 pixels, while PANP can scale to NN4 and NN5 with only a modest resource increase.

5. Experimental Evaluation

PANP’s effectiveness is demonstrated by experiments on synthetic Gaussian process images and real-world datasets such as CIFAR-10 and CelebA at resolutions up to NN6. Comparisons are drawn with NP, pixel-level ANP, ViT-style reconstruction baselines, and MAE:

  • On CIFAR-10 (NN7), PANP reduces mean squared error (MSE) by approximately 10% relative to pixel-level ANP and by 20% relative to NP.
  • PANP matches or slightly outperforms pixel-level ANP at low resolutions. At higher resolutions, where ANP becomes computationally prohibitive, PANP remains tractable, making it suitable for high-resolution tasks.
  • Qualitative results show improved preservation of global image structure (shapes and colors) and fine textures within patches.

Performance metrics in these evaluations include test log-likelihood, MSE on held-out patches, and image reconstruction metrics such as PSNR and SSIM.

6. Strengths, Limitations, and Future Directions

PANP overcomes the core scalability bottleneck of ANP by using patch-wise attention, enabling attention-based Neural Processes for high-resolution images and other large structured data. The architecture’s two-path design maintains both global generative ability (via the latent NN8) and target-specific adaptation (via cross-attention). However, some loss of detail may occur at patch boundaries unless patch size NN9 is chosen sufficiently small, and while NN0, attention cost is still NN1. This suggests a tradeoff: very fine patches recover per-pixel detail but increase costs.

Potential extensions include:

  • Hierarchical patch attention, spanning multiple patch scales.
  • Sparse or localized attention mechanisms to further improve scalability.
  • Generalization to video or 3D domains via spatio-temporal or volumetric patches.
  • Integrating convolutional inductive biases directly into the Transformer blocks.

In summary, PANP generalizes Attentive Neural Processes to high-resolution, patch-wise image regression with efficient attention, combining the strengths of NP/ANP meta-learning and ViT/MAE-style patch representation to produce a tractable, flexible regressor for visual tasks (Yu et al., 2022).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Patch Attentive Neural Processes (PANP).