S4ND: Modeling Images and Videos as Multidimensional Signals Using State Spaces

Eric Nguyen, Karan Goel, Albert Gu, Gordon W. Downs, Preey Shah, Tri Dao, Stephen A. Baccus, Christopher RéarXiv 2022

Abstract

Visual data such as images and videos are typically modeled as discretizations of inherently continuous, multidimensional signals. Existing continuous-signal models attempt to exploit this fact by modeling the underlying signals of visual (e.g., image) data directly. However, these models have not yet been able to achieve competitive performance on practical vision tasks such as large-scale image and video classification. Building on a recent line of work on deep state space models (SSMs), we propose S4ND, a new multidimensional SSM layer that extends the continuous-signal modeling ability of SSMs to multidimensional data including images and videos. We show that S4ND can model large-scale visual data in 1D, 2D, and 3D as continuous multidimensional signals and demonstrates strong performance by simply swapping Conv2D and self-attention layers with S4ND layers in existing state-of-the-art models. On ImageNet-1k, S4ND exceeds the performance of a Vision Transformer baseline by 1.5% when training with a 1D sequence of patches, and matches ConvNeXt when modeling images in 2D. For videos, S4ND improves on an inflated 3D ConvNeXt in activity classification on HMDB-51 by 4%. S4ND implicitly learns global, continuous convolutional kernels that are resolution invariant by construction, providing an inductive bias that enables generalization across multiple resolutions. By developing a simple bandlimiting modification to S4 to overcome aliasing, S4ND achieves strong zero-shot (unseen at training time) resolution performance, outperforming a baseline Conv2D by 40% on CIFAR-10 when trained on 8x8 and tested on 32x32 images. When trained with progressive resizing, S4ND comes within ~1% of a high-resolution model while training 22% faster.

Introduction

Most modern computer vision models, such as Convolutional Neural Networks (CNNs) and Vision Transformers (ViTs), treat visual data as discrete grids of pixels. However, images and videos are actually discretizations of inherently continuous, multidimensional signals. While 1D State Space Models (SSMs) like S4 have revolutionized long-sequence modeling in domains like audio, they previously could not be applied directly to multidimensional visual data. Existing "continuous-signal" models often struggled to achieve competitive performance on large-scale benchmarks like ImageNet. S4ND aims to bridge this gap, creating a model that respects the continuous nature of visual data while maintaining the performance of top-tier discrete models.

Methods

The core technical contribution is the S4ND layer, which generalizes the 1D SSM (governed by an Ordinary Differential Equation) into a multidimensional Partial Differential Equation (PDE).

Factored Kernels and Global Receptive Fields

To avoid the exponential parameter growth typical of multidimensional models, S4ND factors the ND kernel into a tensor product of 1D SSM kernels. This makes the layer efficient and easy to implement using 1D S4 layers as building blocks. Unlike standard CNNs that use small local kernels (e.g., 3x3), S4ND learns global convolutional kernels that span the entire input dimensions (e.g., 224x224). This allows the model to capture global context without the quadratic complexity of self-attention.

The S4ND workflow: initializing SSM parameters, creating factored kernels via outer products, and replacing local convolutions in standard architectures like ResBlocks.

Bandlimiting for Resolution Invariance

Because S4ND learns a continuous kernel, it can theoretically be sampled at any resolution. However, simply upsampling can lead to aliasing. The authors developed a bandlimiting modification: a low-pass filtering step that masks out high-frequency coefficients in the kernel exceeding the Nyquist frequency of a target resolution. This prevents aliasing artifacts that typically degrade performance when scaling to higher resolutions than seen during training.

Overview of S4ND convolution and the bandlimiting process used to ensure resolution invariance by discretizing continuous signals.

Results

The model was evaluated on several standard benchmarks, demonstrating its versatility as a drop-in replacement for standard vision layers.

  • Image Performance: On ImageNet-1k, S4ND-ViT achieved 80.4% top-1 accuracy, outperforming the ViT-B baseline by 1.5%. S4ND-ConvNeXt matched the performance of the state-of-the-art ConvNeXt-T at 82.2%.
  • Video Performance: By "inflating" a 2D model to 3D, S4ND achieved 62.1% on HMDB-51, a 4% improvement over a similarly inflated ConvNeXt baseline.
  • Zero-Shot Scaling: In a dramatic test on CIFAR-10, S4ND outperformed standard Conv2D by 40% when trained on 8x8 images and tested on 32x32, demonstrating the power of the continuous inductive bias.
  • Efficiency: Using "progressive resizing" (starting training at low resolution and increasing), S4ND trained 22% faster than a high-resolution baseline while staying within 1% of the final accuracy.

Discussion

While S4ND shows great promise, it currently faces some practical hurdles. It is about 2x slower than highly optimized local Conv2D implementations in 2D settings due to a lack of kernel fusion in current libraries. Additionally, the use of Fast Fourier Transforms (FFTs) for global convolutions can be memory-intensive. Future work includes exploring temporal zero-shot resolution (e.g., varying frame rates) and applying S4ND to irregular sampling rates and even larger video datasets.

Summary updated

BibTeX
@misc{nguyen2022s,
  author = {Eric Nguyen and Karan Goel and Albert Gu and Gordon W. Downs and Preey Shah and Tri Dao and Stephen A. Baccus and Christopher Ré},
  title = {{S4ND: Modeling Images and Videos as Multidimensional Signals Using State Spaces}},
  year = {2022},
  eprint = {2210.06583},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.06583},
}
Figure