SimpleShotOptions<T, TInput, TOutput>

Options & Configuration · AiDotNet.MetaLearning.Options

Configuration options for SimpleShot (Wang et al., 2019) few-shot classification.

Inheritance: ModelOptions → SimpleShotOptions<T, TInput, TOutput>

Implements: IMetaLearnerOptions<T>

For Beginners

SimpleShot shows that simple methods can be surprisingly effective:

The approach:

  1. Train a good feature extractor on the base classes (standard training, no episodes)
  2. For a new few-shot task:
  • Extract features for all support and query examples
  • Normalize the features (L2 norm or centered L2 norm)
  • Compute class centroids from support features
  • Classify query examples by nearest centroid

Why it works: Many complex meta-learning methods spend effort on task-specific adaptation, but a well-trained feature extractor with proper normalization already produces features where nearest-centroid works well.

Normalization methods:

  • L2: Normalize each feature vector to unit length
  • CL2N: Center features (subtract mean), then L2 normalize
  • CL2N typically works better because it removes the “bias” in feature space

How It Works

SimpleShot demonstrates that nearest-centroid classification with proper feature normalization (L2 or CL2N) can match or exceed many complex meta-learning methods. It requires no task-specific adaptation - just normalize features and compare distances.

Reference: Wang, Y., Chao, W.L., Weinberger, K.Q., & van der Maaten, L. (2019). SimpleShot: Revisiting Nearest-Neighbor Classification for Few-Shot Learning.

Constructors

Constructor Summary
SimpleShotOptions(IFullModel<T, TInput, TOutput> metaModel) Initializes a new instance of SimpleShotOptions.

Properties

Property Summary
IEpisodicDataLoader<T, TInput, TOutput> DataLoader { get; set; } Gets or sets the episodic data loader.
IFullModel<T, TInput, TOutput> MetaModel { get; set; } Gets or sets the feature extractor model.
IGradientBasedOptimizer<T, TInput, TOutput> InnerOptimizer { get; set; } Must stay null: this algorithm takes no plain gradient inner step (it adapts without one, or by its own update rule), so a supplied optimizer is rejected when the learner is built.
IGradientBasedOptimizer<T, TInput, TOutput> MetaOptimizer { get; set; } Optimizer for the meta-update.
ILossFunction<T> LossFunction { get; set; } Loss function for meta-training; null uses the default multi-class classification loss.
bool EnableCheckpointing { get; set; }
bool UseFirstOrder { get; set; }
double InnerLearningRate { get; set; }
double OuterLearningRate { get; set; }
double? GradientClipThreshold { get; set; }
int AdaptationSteps { get; set; } Number of gradient steps taken on each task’s support set (0: this algorithm adapts without gradient steps).
int CheckpointFrequency { get; set; }
int EvaluationFrequency { get; set; }
int EvaluationTasks { get; set; }
int MetaBatchSize { get; set; }
int NumMetaIterations { get; set; }
int? RandomSeed { get; set; } Gets or sets the random seed.
string DistanceMetric { get; set; } Gets or sets the distance metric for nearest-centroid classification.
string NormalizationType { get; set; } Gets or sets the feature normalization method.

Methods

Method Summary
IMetaLearnerOptions<T> Clone()
bool IsValid()