Multi-Dimensional Hyena for Spatial Inductive Bias

Itamar Zimerman, Lior Wolf

Abstract

The advantage of Vision Transformers over CNNs is only fully manifested when trained over a large dataset, mainly due to the reduced inductive bias towards spatial locality within the transformer’s self-attention mechanism. In this work, we present a data-efficient vision transformer that does not rely on self-attention. Instead, it employs a novel generalization to multiple axes of the very recent Hyena layer. We propose several alternative approaches for obtaining this generalization and delve into their unique distinctions and considerations from both empirical and theoretical perspectives. The proposed Hyena N-D layer boosts the performance of various Vision Transformer architectures, such as ViT, Swin, and DeiT across multiple datasets. Furthermore, in the small dataset regime, our Hyena-based ViT is favorable to ViT variants from the recent literature that are specifically designed for solving the same challenge. Finally, we show that a hybrid approach that is based on Hyena N-D for the first layers in ViT, followed by layers that incorporate conventional attention, consistently boosts the performance of various vision transformer architectures.

Introduction

Vision Transformers (ViTs) have revolutionized computer vision, yet they face significant challenges compared to traditional Convolutional Neural Networks (CNNs). Specifically, ViTs suffer from two primary "taxes":

  1. The Data Tax: Transformers lack inherent spatial inductive bias. They do not automatically recognize that neighboring pixels are related, requiring massive datasets to learn 2D structures.
  2. The Complexity Tax: Self-attention mechanisms exhibit quadratic complexity ($O(L^2)$) relative to sequence length, making high-resolution image processing computationally expensive.

This research introduces the Multi-Dimensional Hyena (Hyena N-D) layer, an architectural building block designed to bring CNN-like spatial inductive bias to the global-context framework of Transformers while maintaining sub-quadratic complexity.

Methodology: Generalizing Hyena to N-Dimensions

The core of this work is the extension of the Hyena hierarchy—a recent attention alternative using long convolutions with implicit filters—to multiple dimensions.

Hyena N-D Implicit Filters

Standard Hyena uses a Feed-Forward Network (FFN) to generate filter weights based on 1D positional coordinates. The authors propose two main 2D extensions:

  • Hyena 2-D Product: Multiplies independent 1D filters. While efficient, this limits the filter to a "rank-1" tensor, restricting its ability to capture complex spatial textures.
  • Hyena 2-D: Uses a single FFN taking N-D coordinates as input. This approach allows for high-rank filters, significantly increasing expressiveness.
Figure 1: Sequence structure and architectural variants of Hyena layers (Original, 2-D, and 2-D Product).

Spatial Bias and Gating

To incorporate locality bias, the authors apply a decaying N-D Windowing function to the generated filters. Furthermore, since images lack the inherent causality of 1D sequences, the authors introduced multi-directional gating (2-directional and 4-directional variants) to allow the model to process information in all spatial directions.

Experimental Results

The models were evaluated on CIFAR-100, Tiny-ImageNet, and CelebA to test performance across various scales and resolutions.

Accuracy and Data Efficiency

Hyena 2-D demonstrated significant improvements over standard ViT-Attention, particularly in data-constrained environments. On CIFAR-100, replacing attention with Hyena 2-D improved accuracy by 1.44%, and on Tiny-ImageNet, the improvement reached 2.61%. The "Hyena-First" hybrid model—using Hyena layers for early spatial processing and attention for deep global integration—performed best, outperforming standard ViT by ~4.23% on Tiny-ImageNet.

Computational Efficiency

By utilizing Fast Fourier Transforms (FFTs) for convolution, Hyena N-D achieves $O(L \log L)$ complexity. This leads to massive memory savings as image resolution increases.

Figure 3: Peak GPU memory usage comparison between ViT-Attention and ViT-Hyena 2-D across different patch counts.

As shown in Figure 3, for high-resolution inputs with over 12,000 patches, Hyena-ViT consumes approximately 5x less peak GPU memory than standard attention-based models.

Conclusion and Future Work

The Multi-Dimensional Hyena layer successfully bridges the gap between the spatial efficiency of CNNs and the global reach of Transformers. While the current implementation requires global pooling due to the removal of the CLS token, future work will explore better integration of conditioning signals. The mathematical framework is naturally extensible to 3D (video) and other N-D modalities, presenting a promising path for multi-modal deep learning.

Summary updated

BibTeX
@inproceedings{zimerman2024multi,
  author = {Itamar Zimerman and Lior Wolf},
  title = {{Multi-Dimensional Hyena for Spatial Inductive Bias}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2024},
  url = {https://openreview.net/forum?id=sFducT8ZE6},
}
Figure