ANILModel<T, TInput, TOutput>

Models & Types · AiDotNet.MetaLearning.Models

ANIL model for few-shot classification with head-only adaptation.

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

For Beginners

After ANIL adapts to a new task by training only the classification head on support examples, this model stores the body and that adapted head, and uses both to score new examples.

How It Works

This model stores the adapted state of ANIL after inner-loop adaptation: the body (feature extractor) and the head adapted to one task. It classifies every example: the body embeds each row, and the head scores each embedding, so a batch of n examples yields [n, NumClasses] scores.

Constructors

Constructor Summary
ANILModel(IFullModel<T, TInput, TOutput> featureExtractor, Vector<T> headWeights, Vector<T> headBias, ANILOptions<T, TInput, TOutput> options) Initializes a new instance of the ANILModel.

Properties

Property Summary
ModelMetadata<T> Metadata { get; }
Vector<T> HeadBias { get; } Gets the adapted head bias (may be null if not used).
Vector<T> HeadWeights { get; } Gets the adapted 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)