BOILModel<T, TInput, TOutput>

Models & Types · AiDotNet.MetaLearning.Models

BOIL model for few-shot classification with body-only adaptation.

Implements: IModel<TInput, TOutput, ModelMetadata<T>>

For Beginners

After BOIL adapts its feature extractor to a new task, this model stores that adapted extractor together with the shared classifier head, and uses both to score new examples.

How It Works

The adapted state of BOIL for one task: its own copy of the body, carrying the parameters the inner loop adapted, and the head, which the inner loop does not change. The body embeds every row and the head scores each embedding, so a batch of n examples yields [n, NumClasses] scores.

Constructors

Constructor Summary
BOILModel(IFullModel<T, TInput, TOutput> baseModel, Vector<T> adaptedBodyParams, Vector<T> headWeights, Vector<T> headBias, BOILOptions<T, TInput, TOutput> options) Initializes a new instance of the BOILModel.

Properties

Property Summary
ModelMetadata<T> Metadata { get; }
Vector<T> AdaptedBodyParams { get; } Gets the adapted body parameters.
Vector<T> HeadBias { get; } Gets the head bias (may be null if not used).
Vector<T> HeadWeights { get; } Gets the head weights.
int FeatureDimension { get; } Gets the feature dimension expected by the head.
int NumClasses { get; } Gets the number of classes this model is adapted for.

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
TOutput Predict(TInput input)
Vector<T> GetParameters()
void Train(TInput inputs, TOutput targets)
void UpdateParameters(Vector<T> parameters)