Abstract
Neural processes (NPs) learn stochastic processes and predict the distribution of target output adaptively conditioned on a context set of observed input-output pairs. Furthermore, Attentive Neural Process (ANP) improved the prediction accuracy of NPs by incorporating attention mechanism among contexts and targets. In a number of real-world applications such as robotics, finance, speech, and biology, it is critical to learn the temporal order and recurrent structure from sequential data. However, the capability of NPs capturing these properties is limited due to its permutation invariance instinct. In this paper, we proposed the Recurrent Attentive Neural Process (RANP), or alternatively, Attentive Neural Process-Recurrent Neural Network (ANP-RNN), in which the ANP is incorporated into a recurrent neural network. The proposed model encapsulates both the inductive biases of recurrent neural networks and also the strength of NPs for modelling uncertainty. We demonstrate that RANP can effectively model sequential data and outperforms NPs and LSTMs remarkably in a 1D regression toy example as well as autonomous-driving applications.
Introduction
Modeling sequential data—found in everything from robotics to finance—requires two distinct capabilities: capturing temporal dependencies (the order of events) and quantifying uncertainty. Existing methods often force a trade-off. Neural Processes (NPs) are excellent at estimating uncertainty and adapting to new tasks with few observations, but they are "permutation invariant," meaning they treat a sequence of data points like a bag of marbles, ignoring chronological order. Conversely, LSTMs and RNNs are the gold standard for temporal order but typically provide point estimates rather than full probability distributions, making them "uncertainty-blind." Gaussian Processes (GPs) offer uncertainty but are computationally heavy and difficult to scale.
The Recurrent Attentive Neural Process (RANP) bridges this gap by preserving the temporal "arrow of time" while maintaining the flexible uncertainty modeling of the Neural Process family.
Methodology
The core innovation is the integration of a Long Short-Term Memory (LSTM) network into the Attentive Neural Process (ANP) architecture. As shown in the model architecture below, the process works in three main stages:
- Temporal Encoding: Instead of feeding raw $(x, y)$ pairs directly into the encoder, the input sequences are first processed by an LSTM ($\Phi$). This transforms the raw data into latent representations ($h_i$) that encapsulate the historical context and temporal order.
- Dual-Path Processing:
- Deterministic Path: Uses a Cross-Attention Network to allow target queries to "attend" to specific, relevant parts of the observed context.
- Latent Path: Captures global uncertainty by modeling a stochastic latent variable ($z$).
- Probabilistic Decoding: The decoder combines the temporal features, the attended context, and the global uncertainty variable to output a predictive distribution (mean and variance) for the target.
Experimental Results
The authors evaluated their model on two primary benchmarks: a 1D synthetic regression task generated from a Sine function combined with a Gaussian Process, and the NGSIM (Next Generation Simulation) real-world dataset of vehicle trajectories.
In the 1D regression task, RANP showed a significantly faster and deeper decrease in Negative Log-Likelihood (NLL) compared to standard NPs and ANPs. In the autonomous driving lane-change task, RANP achieved an MSE of 0.1673, vastly outperforming the plain LSTM (MSE 1.45). Qualitatively, RANP successfully tracks the curved path of lane-changing vehicles where other models often collapse to a "mean" straight-line path due to uncertainty blindness.
Discussion and Conclusion
A key insight of this work is that permutation invariance—often cited as a strength of NPs—is a significant liability for time-series. By using an LSTM as a pre-processor, the model "learns" the sequence before the NP part aggregates it. Standard NPs tend to capture the global shape of a function but miss local nuances. As seen in the 1D regression results, RANP (labeled ANP-RNN) is the only model that accurately hugs the local context points while maintaining a sensible global distribution.
While RANP is powerful, there is room to better handle non-stationary dynamics. Future research could explore using different recurrent units or even Transformer-based temporal encoders. Although more efficient than GPs, the addition of the recurrent layer and attention mechanisms adds computational overhead compared to a simple MLP-based NP.
Summary updated