Heracles: A Hybrid SSM-Transformer Model for High-Resolution Image and Time-Series Analysis

Badri N. Patro, Suhas Ranganath, Vinay P. Namboodiri, Vijay S. AgneeswaranarXiv 2024 · DOI

Abstract

Transformers have revolutionized image modeling tasks with adaptations like DeIT, Swin, SVT, Biformer, STVit, and FDVIT. However, these models often face challenges with inductive bias and high quadratic complexity, making them less efficient for high-resolution images. State space models (SSMs) such as Mamba, V-Mamba, ViM, and SiMBA offer an alternative to handle high resolution images in computer vision tasks. These SSMs encounter two major issues. First, they become unstable when scaled to large network sizes. Second, although they efficiently capture global information in images, they inherently struggle with handling local information. To address these challenges, we introduce Heracles, a novel SSM that integrates a local SSM, a global SSM, and an attention-based token interaction module. Heracles leverages a Hartely kernel-based state space model for global image information, a localized convolutional network for local details, and attention mechanisms in deeper layers for token interactions. Our extensive experiments demonstrate that Heracles-C-small achieves state-of-the-art performance on the ImageNet dataset with 84.5% top-1 accuracy. Heracles-C-Large and Heracles-C-Huge further improve accuracy to 85.9% and 86.4%, respectively. Additionally, Heracles excels in transfer learning tasks on datasets such as CIFAR-10, CIFAR-100, Oxford Flowers, and Stanford Cars, and in instance segmentation on the MSCOCO dataset. Heracles also proves its versatility by achieving state-of-the-art results on seven time-series datasets, showcasing its ability to generalize across domains with spectral data, capturing both local and global information.

Introduction

In the current deep learning landscape, Transformers are the undisputed leaders in computer vision and sequence modeling. However, they suffer from a significant limitation: the self-attention mechanism possesses quadratic complexity ($O(N^2)$) relative to the number of input patches. This scaling behavior makes them computationally prohibitive for high-resolution images or long-duration time-series data.

State Space Models (SSMs), such as the recently popularized Mamba architecture, offer a linear-time alternative ($O(N \log N)$) that excels at capturing global dependencies. Despite this efficiency, SSMs face their own hurdles, specifically a struggle to capture fine-grained local details (inductive bias) and potential instability when scaled to massive network sizes. Heracles is designed to bridge this gap, creating a "best of all worlds" model that is efficient, stable, and locally aware.

The Heracles Architecture

Heracles introduces a hybrid "SSM Layer" that processes information through three distinct, integrated paths to ensure comprehensive feature extraction.

The hybrid SSM Layer architecture combining Global and Local SSM paths.

Global SSM with Hartley Kernel

Instead of relying on complex-valued Fourier transforms, Heracles utilizes the Hartley transform. This real-valued transform captures global spectral information without the computational overhead associated with complex numbers. Because the Hartley transform is an involution (it is its own inverse), it provides a mathematically elegant and efficient method for global filtering across the entire image or sequence.

Local SSM and Parallel Convolution

Operating in parallel with the global SSM, Heracles employs a localized convolutional network. This path explicitly injects the necessary inductive bias to understand local textures and edges—details that pure SSMs often overlook. By running these paths in parallel rather than serially, the model fuses local and global features simultaneously, enhancing representational power.

Strategic Hybridization with Attention

While the initial layers prioritize SSMs for computational efficiency, Heracles incorporates standard multi-head self-attention (MHSA) in its deeper layers. This allows the model to perform complex reasoning about token interactions after the primary feature extraction is complete. This hybrid approach narrows the performance gap with massive Transformers while maintaining a manageable FLOP count.

Experimental Results

The authors validated Heracles across a diverse set of benchmarks, including ImageNet-1K, MSCOCO, and various transfer learning datasets.

Performance comparison of Heracles variants against state-of-the-art models on ImageNet-1K.

ImageNet-1K Classification

As shown in the comparative results, Heracles-C-Small achieved a remarkable 84.5% top-1 accuracy, outperforming similar-sized models like Wave-ViT and iFormer. The "Large" variant reached 85.9% accuracy with significantly fewer parameters than comparable high-performing attention-based models like MaxViT. The "Huge" variant further pushed the state-of-the-art to 86.4%.

Versatility Across Domains

Beyond standard image classification, Heracles demonstrated superior performance in:

  • Transfer Learning: Achieving top results on CIFAR-10 (99.2%), CIFAR-100 (91.1%), and Stanford Cars (93.5%).
  • Instance Segmentation: In MSCOCO benchmarks, the Heracles-C-S backbone outperformed Swin-T and ResNet-50 in both bounding box and mask Average Precision (AP).
  • Time-Series Forecasting: Heracles achieved state-of-the-art results across seven multivariate datasets, including Electricity and Weather, proving its robustness in handling spectral data across different domains.

Conclusion

Heracles represents a significant step forward in balancing efficiency and accuracy for high-resolution modeling. By combining the global reach of Hartley-based SSMs with the local precision of convolutions and the reasoning power of attention, it provides a versatile backbone for both vision and time-series tasks. Future work may explore pure frequency-domain alternatives to further reduce complexity while maintaining these performance gains.

Summary updated

Abstract

Transformers have revolutionized image modeling tasks with adaptations like DeIT, Swin, SVT, Biformer, STVit, and FDVIT. However, these models often face challenges with inductive bias and high quadratic complexity, making them less efficient for high-resolution images. State space models (SSMs) such as Mamba, V-Mamba, ViM, and SiMBA offer an alternative to handle high resolution images in computer vision tasks. These SSMs encounter two major issues. First, they become unstable when scaled to large network sizes. Second, although they efficiently capture global information in images, they inherently struggle with handling local information. To address these challenges, we introduce Heracles, a novel SSM that integrates a local SSM, a global SSM, and an attention-based token interaction module. Heracles leverages a Hartely kernel-based state space model for global image information, a localized convolutional network for local details, and attention mechanisms in deeper layers for token interactions. Our extensive experiments demonstrate that Heracles-C-small achieves state-of-the-art performance on the ImageNet dataset with 84.5\% top-1 accuracy. Heracles-C-Large and Heracles-C-Huge further improve accuracy to 85.9\% and 86.4\%, respectively. Additionally, Heracles excels in transfer learning tasks on datasets such as CIFAR-10, CIFAR-100, Oxford Flowers, and Stanford Cars, and in instance segmentation on the MSCOCO dataset. Heracles also proves its versatility by achieving state-of-the-art results on seven time-series datasets, showcasing its ability to generalize across domains with spectral data, capturing both local and global information. The project page is available at this link.\url{https://github.com/badripatro/heracles}
BibTeX
@misc{patro2024heracles,
  author = {Badri N. Patro and Suhas Ranganath and Vinay P. Namboodiri and Vijay S. Agneeswaran},
  title = {{Heracles: A Hybrid SSM-Transformer Model for High-Resolution Image and Time-Series Analysis}},
  year = {2024},
  eprint = {2403.18063},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.18063},
}
Figure