VisualBERT<T>
Models & Types · AiDotNet.VisionLanguage.Foundational
VisualBERT: single-stream transformer that concatenates visual and text tokens.
Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → VisualBERT<T>
Implements: IVisionLanguageFusionModel<T>
For Beginners
VisualBERT is a vision-language model. Default values follow the original paper settings.
How It Works
VisualBERT (Li et al., 2019) concatenates Faster R-CNN region features with text token embeddings and processes them in a single BERT-style transformer, enabling implicit cross-modal alignment through self-attention over the combined sequence.
References:
- Paper: “VisualBERT: A Simple and Performant Baseline for Vision and Language” (Li et al., 2019)
Example
// Create a VisualBERT model for vision-language understanding
// with concatenated visual and text tokens in a single BERT stream
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.TwoDimensional,
taskType: NeuralNetworkTaskType.ImageClassification,
inputHeight: 224, inputWidth: 224, inputDepth: 3, outputSize: 512);
// ONNX inference mode with pre-trained model
var model = new VisualBERT<double>(architecture, "visualbert.onnx");
// Training mode with native layers
var trainModel = new VisualBERT<double>(architecture, new VisualBERTOptions());
Constructors
| Constructor | Summary |
|---|---|
VisualBERT(NeuralNetworkArchitecture<T> architecture, VisualBERTOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
|
VisualBERT(NeuralNetworkArchitecture<T> architecture, string modelPath, VisualBERTOptions options) |
Properties
| Property | Summary |
|---|---|
int EmbeddingDimension { get; } |
|
int FusionEmbeddingDim { get; } |
|
int MaxSequenceLength { get; } |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
T ComputeMatchingScore(Tensor<T> image, string text) |
|
Tensor<T> EncodeImage(Tensor<T> image) |
|
Tensor<T> ForwardForTraining(Tensor<T> input) |
|
Tensor<T> FuseImageText(Tensor<T> image, string text) |