Vision Mamba Mender

Jiacong Hu, Anda Cao, Zunlei Feng, Shengxuming Zhang, Yi Wang, Lingxiang Jia, Mingli Song

State Space Models (SSMs) like Mamba are rapidly emerging as powerful alternatives to Convolutional Neural Networks (CNNs) and Vision Transformers (ViTs) in computer vision. They offer a global receptive field combined with linear computational complexity, solving the limited receptive fields of CNNs and the quadratic scaling issues of ViTs. However, adapting Mamba for vision tasks has largely relied on trial-and-error architectural tweaks, such as modifying the model's scanning mechanisms.

Rather than blindly changing the architecture, the paper Vision Mamba Mender takes a systematic approach: diagnosing exactly why a Mamba model misclassifies an image and automatically repairing these internal flaws during training without adding any parameters.

Diagnosing Mamba's States

To understand the model's decision-making, the authors divide Mamba's operations into two distinct categories:

  1. External State Interactions: How different image patches (states) communicate with each other via Convolution and SSM modules.
  2. Internal State Interactions: How a single image patch processes its own information via linear mapping layers.
Mamba Block Architecture

To visualize what these states are doing, the researchers introduce two gradient-based attribution methods inspired by Grad-CAM: Grad-ESC and Grad-ISC. These tools calculate "Correlation Scores" to reveal exactly what the external and internal states are focusing on during inference.

Visualizing and Repairing Flaws

Using these diagnostic tools, the authors discovered highly interpretable reasons for Mamba's failures. When the model struggles with a "difficult" image, its external states are usually distracted by background elements. Simultaneously, its internal states become highly inconsistent compared to how they process "easy" images of the exact same class.

Grad-ESC Visualizations on Image Patches

To fix these specific flaws, the Vision Mamba Mender framework introduces two new loss functions during the training phase:

  • External Repair: This uses ground-truth foreground segmentation masks (sourced from datasets like ImageNet-S) to force the model's external states (Conv/SSM outputs) to focus strictly on the foreground object, ignoring background noise.
  • Internal Repair: This creates a "clean" internal state template derived from easy samples of a given class. It then forces the model to align its internal states with this template when processing harder, more complex images.

Because these repairs are applied entirely as loss constraints during training, the final optimized model requires zero additional parameters and runs just as fast as the baseline model during inference.

Experimental Validation

The authors tested their Mender framework across five state-of-the-art Vision Mamba architectures (ViM, VMamba, SiMBA, EMamba, and LocalViM) using ImageNet-50, ImageNet-300, and the full ImageNet-1K dataset.

  • Massive Gains on Smaller Scales: On ImageNet-50, applying both internal and external repairs boosted the accuracy of ViM-T by 3.24% (from 76.44% to 79.68%) and SiMBA-S by a massive 5.20%.
  • Consistent Gains on Large Scales: On the full ImageNet-1K dataset, the repairs improved ViM-T's accuracy by +1.66% (from 71.64% to 73.30%) and LocalViM-T by +3.13%.

Ablation studies confirmed that fixing how tokens talk to each other (external) and how they process themselves (internal) are orthogonal improvements. Applying both repairs simultaneously always outperformed repairing just one or the other.

Limitations and Future Directions

While the Vision Mamba Mender successfully analyzes the inputs and outputs of the Mamba block's modules, it currently treats the intricate mathematics inside the core Selective SSM module as a black box. The authors hypothesize that further flaws might exist deep within the SSM's internal equations. Future work will likely dive into the granular details of the SSM module itself. Additionally, this diagnostic "mending" paradigm could easily be expanded beyond computer vision to NLP tasks or applied to other novel network architectures.

Summary updated

BibTeX
@inproceedings{hu2024vision,
  author = {Jiacong Hu and Anda Cao and Zunlei Feng and Shengxuming Zhang and Yi Wang and Lingxiang Jia and Mingli Song},
  title = {{Vision Mamba Mender}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=9VnevS2YoR},
}
Figure