VisionMambaModel<T>

Models & Types · AiDotNet.NeuralNetworks

Vision Mamba (Vim) image classification: the official network with a linear classifier on its class token.

Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → ImageClassifierModelLayoutBase<T> → VisionMambaModel<T>

For Beginners

This model classifies images using Mamba instead of attention. It cuts the image into small patches, reads them forwards and backwards with Mamba blocks (fast sequence processing), and outputs class probabilities. Vision Mamba needs O(n) computation vs O(n^2) for Transformers, making it faster for high-resolution images.

How It Works

The image is cut into patches; a class token is inserted in the middle of the patch sequence; each layer runs a bidirectional Mamba mixer (a forward and a backward selective-scan branch, averaged) on the RMS-normalized residual stream; and the class token’s final features are classified. The network is shared with the Vision Mamba segmenter and checked against the official code (hustvl/Vim).

Reference: Zhu et al., “Vision Mamba: Efficient Visual Representation Learning with Bidirectional State Space Model”, ICML 2024.

Constructors

Constructor Summary
VisionMambaModel(NeuralNetworkArchitecture<T> architecture, VisionMambaOptions options, ILossFunction<T> lossFunction, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) Creates a Vision Mamba classifier.

Properties

Property Summary
bool SupportsTraining { get; }
int ImageHeight { get; }
int ImageWidth { get; }
int ModelDimension { get; }
int NumClasses { get; }
int NumLayers { get; }
int NumPatches { get; }
int PatchSize { get; }

Methods

Method Summary
Dictionary<string, Tensor<T>> GetNamedLayerActivations(Tensor<T> input)
ModelMetadata<T> GetModelMetadata()
Tensor<T> Forward(Tensor<T> input) The class probabilities of an image [C, H, W] or a batch [B, C, H, W].
Tensor<T> ForwardForTraining(Tensor<T> input)