FEATAlgorithm<T, TInput, TOutput>
Models & Types · AiDotNet.MetaLearning.Algorithms
Implementation of FEAT (Few-shot Embedding Adaptation with Transformer).
Inheritance: ModelBase<T, TInput, TOutput> → MetaLearnerBase<T, TInput, TOutput> → FEATAlgorithm<T, TInput, TOutput>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
FEAT makes prototypes smarter by letting them “see” each other:
The insight: ProtoNets computes each class prototype in isolation. But if you know that class A and class B are very similar, you should push their prototypes apart to avoid confusion. FEAT uses a transformer to automatically learn these adjustments.
How it works:
- Compute initial prototypes (mean of support features per class, like ProtoNets)
- Feed ALL prototypes through a transformer
- The transformer uses self-attention so each prototype can “see” all others
- It learns to adjust prototypes based on the specific set of classes
- Use the adapted prototypes for nearest-prototype classification
- Train with both classification loss AND contrastive loss
Why the transformer helps:
- In a 5-way task with dogs vs cats: Prototypes need to capture species differences
- In a 5-way task with dog breeds: Same dog features need to capture breed differences
- The transformer adjusts prototypes based on what’s needed for THIS specific task
How It Works
FEAT uses a set-to-set transformer to adapt class prototypes based on inter-class relationships. Initial prototypes (class means) are fed through the transformer, which outputs task-adapted prototypes that are more discriminative.
Algorithm - FEAT:
Reference: Ye, H.J., Hu, H., Zhan, D.C., & Sha, F. (2020). Few-Shot Learning via Embedding Adaptation with Set-to-Set Functions. CVPR 2020.
Constructors
| Constructor | Summary |
|---|---|
FEATAlgorithm(FEATOptions<T, TInput, TOutput> options) |
Initializes a new FEAT meta-learner. |
Properties
| Property | Summary |
|---|---|
MetaLearningAlgorithmType AlgorithmType { get; } |
Methods
| Method | Summary |
|---|---|
IModel<TInput, TOutput, ModelMetadata<T>> Adapt(IMetaLearningTask<T, TInput, TOutput> task) |
Adapts to a new task using transformer-adapted prototypes. |
T MetaTrain(TaskBatch<T, TInput, TOutput> taskBatch) |
Performs one meta-training step for FEAT. |