Florence2ProjectorLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

Florence-2’s visual projector (HF Florence2MultiModalProjector). It turns DaViT’s last feature map into the image tokens that are spliced into the language encoder.

Inheritance: LayerBase<T> → Florence2ProjectorLayer<T>

Implements: IShapeContract

How It Works

The steps are:

  • Add a learned 2-D position embedding. Its first half comes from a column table and its second half from

a row table.

  • Flatten the map and add the 1-D cosine temporal embedding of frame 0.
  • Prepend the mean over all positions as one extra token.
  • Project with a bias-free linear layer, then apply LayerNorm. The result is 1 + h*w tokens.

Constructors

Constructor Summary
Florence2ProjectorLayer(int visionDim, int projectionDim, int grid, int maxPositions)

Properties

Property Summary
bool SupportsTraining { get; }
int TokenCount { get; } Number of image tokens produced: the mean token plus one per position.

Methods

Method Summary
Dictionary<string, string> GetParameterRoles() Returns parameter roles for per-role optimizer configuration (e.g., weight decay exemption for biases).
IReadOnlyList<ILayer<T>> GetSubLayers()
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
IReadOnlyList<Tensor<T>> GetTrainableParameters() Returns all trainable parameter tensors marked with [TrainableParameter].
void ResetState()
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) Replaces trainable parameter tensors (e.g., with ParameterBuffer views).
void ZeroGrad() Clears all gradient fields discovered by convention ({paramName}Gradient).