Continuous Spatiotemporal Transformer

Antonio Henrique de Oliveira Fonseca, Emanuele Zappala, Josue Ortega Caro, David van DijkICML 2023

TL;DR

The Continuous Spatiotemporal Transformer (CST) bridges the gap between discrete sequence modeling and continuous dynamical systems. By incorporating Sobolev space optimization and "dummy" coordinate sampling, CST ensures smooth, continuous outputs that outperform standard Transformers and specialized physics-informed models in tasks ranging from fluid dynamics to brain imaging.

The Discreteness Problem in Transformers

Transformers have revolutionized natural language processing and computer vision by capturing long-range dependencies through self-attention. However, they suffer from a fundamental "discreteness" problem. They treat data as a sequence of isolated tokens, making them ill-suited for modeling continuous dynamical systems—like fluid flow or the spiking activity of a brain—where time and space form a continuous manifold.

When a standard Transformer is asked to interpolate or predict a state at an unseen time point, it often produces "step-like" or jagged outputs. It lacks a mathematical guarantee of smoothness. In fields like physics and biology, where calculating derivatives or understanding transitions between sparsely sampled data points is crucial, this "jitter" represents a failure to capture the underlying physical reality.

Introducing the Continuous Spatiotemporal Transformer (CST)

To address these limitations, the authors introduce the Continuous Spatiotemporal Transformer (CST), which modifies the standard architecture in three key ways:

CST Architecture and Methodology
  1. Sobolev Space Optimization: Instead of relying solely on a simple Mean Squared Error (MSE) loss, CST incorporates a Sobolev loss. This function penalizes not just the difference between the prediction and the ground truth, but also the "roughness" of the output by minimizing the $p$-norm of higher-order derivatives. This forces the model to produce functions that are both accurate and mathematically smooth.
  2. Dummy Coordinate Sampling: During training, the model is fed a mix of real data points and "dummy" points (initialized via linear interpolation). The model must predict meaningful values at these arbitrary "in-between" coordinates, effectively learning the continuous landscape of the data rather than memorizing a discrete sequence.
  3. Linear Attention: Because adding dummy points increases the sequence length, the authors utilize a linear attention mechanism. This ensures the computational cost scales linearly ($O(n)$) with the number of points, keeping the model efficient even for high-resolution interpolation.

Key Insights and Performance

The authors benchmarked CST across diverse domains, including synthetic 2D spirals, KITTI video reconstruction, Navier-Stokes fluid dynamics, and widefield calcium imaging of mouse brains.

Interpolation Performance: CST vs. Standard Transformer
  • Eliminating the "Step-Like" Artifact: One of the most striking insights is the visual failure of standard Transformers during interpolation. Even when fitting training data perfectly, their predictions between points resemble a staircase. CST’s Sobolev prior effectively "sands down" these edges, creating a smooth, continuous curve.
  • Superior Interpolation: On the 2D spiral task, CST achieved significantly lower interpolation error ($P < 0.0001$) compared to standard Transformers, which struggled with noise and irregular sampling.
  • Robustness to Sparsity: CST excels when data is irregularly sampled. By treating the domain as continuous, it seamlessly models transitions regardless of the temporal gap between data points.
  • Up-sampling Attention: Because CST is continuous, attention weights can be evaluated at any arbitrary coordinate. The model can accurately "up-sample" its own internal attention maps, providing a higher-resolution view of spatiotemporal interactions than the raw data allows.
  • Real-World Efficacy: In the KITTI inpainting task, CST achieved an MSE of 0.1138, vastly outperforming 3D-ViT (0.2505) and ConvGRU (0.363). For fluid dynamics, CST outperformed Fourier Neural Operators (FNOs) on noisy Navier-Stokes data due to its resilience to real-world jitter. Furthermore, when decoding brain activity, CST-base achieved an $R^2$ of 0.774 in regressing visual contrast, significantly beating popular neuroscience models like LFADS (0.609) and ViViT (0.637).

Limitations and Future Work

While linear attention mitigates some overhead, the computational cost still grows with the number of "dummy" points added, leading to increased GPU memory usage at higher resolutions. Additionally, while the authors focused on 2D and 3D systems, scaling this approach to even higher-dimensional physical systems remains an open challenge. Future work may involve applying CST to climate modeling or complex multi-agent dynamical systems where continuous time and space modeling is critical.

Summary updated

BibTeX
@inproceedings{fonseca2023continuous,
  author = {Antonio Henrique de Oliveira Fonseca and Emanuele Zappala and Josue Ortega Caro and David van Dijk},
  title = {{Continuous Spatiotemporal Transformer}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=RnZhB7kNl0},
}
Figure