SetFeatAlgorithm<T, TInput, TOutput>

Models & Types · AiDotNet.MetaLearning.Algorithms

Implementation of SetFeat (set-feature based few-shot learning) (Afrasiyabi et al., CVPR 2022).

Inheritance: ModelBase<T, TInput, TOutput> → MetaLearnerBase<T, TInput, TOutput> → SetFeatAlgorithm<T, TInput, TOutput>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

SetFeat treats each class as a SET, not just a single point:

The problem with prototypes: ProtoNets computes the MEAN of support examples. This throws away information about HOW the class varies. Two classes might have the same mean but very different spreads.

How SetFeat fixes this:

  1. Extract features for each class’s support examples
  2. Feed ALL examples (as a set) into a set encoder
  3. The set encoder captures rich information: mean, variance, relationships
  4. Optional cross-attention lets classes “see” each other for context
  5. The resulting set-features are used for classification

Example: If you have 5 examples of cats (tabby, persian, siamese, calico, sphinx):

  • ProtoNets: Average them into one “generic cat” point
  • SetFeat: Encodes that cats come in different fur patterns and body types

This extra information helps distinguish cats from similar classes like small dogs.

How It Works

SetFeat learns set-level features by processing each class’s support examples as a set rather than individual instances. A set encoder with optional cross-attention computes class representations that capture intra-class variation.

Algorithm - SetFeat:

Reference: Afrasiyabi, A., Larochelle, H., Lalonde, J.F., & Gagne, C. (2022). Matching Feature Sets for Few-Shot Image Classification. CVPR 2022.

Constructors

Constructor Summary
SetFeatAlgorithm(SetFeatOptions<T, TInput, TOutput> options) Initializes a new SetFeat meta-learner.

Properties

Property Summary
MetaLearningAlgorithmType AlgorithmType { get; }

Methods

Method Summary
IModel<TInput, TOutput, ModelMetadata<T>> Adapt(IMetaLearningTask<T, TInput, TOutput> task)
T MetaTrain(TaskBatch<T, TInput, TOutput> taskBatch)