ProtoNetsOptions<T, TInput, TOutput>

Options & Configuration · AiDotNet.MetaLearning.Options

Configuration options for Prototypical Networks (ProtoNets) algorithm.

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

Implements: IMetaLearnerOptions<T>

For Beginners

ProtoNets is one of the simplest and most effective few-shot learning methods:

  1. Use a neural network to convert images/data into feature vectors
  2. For each class in a task, compute the “prototype” (average feature vector)
  3. To classify a new example, find the nearest prototype
  4. Train the network to make same-class examples cluster together

Unlike MAML, ProtoNets doesn’t need gradient updates at test time - just compute prototypes and measure distances!

How It Works

Prototypical Networks learn a metric space where classification is performed by computing distances to prototype representations of each class. Each prototype is the mean vector of the support set examples for that class in the learned embedding space.

Constructors

Constructor Summary
ProtoNetsOptions(IFullModel<T, TInput, TOutput> metaModel) Initializes a new instance of the ProtoNetsOptions class with the required meta-model.

Properties

Property Summary
IEpisodicDataLoader<T, TInput, TOutput> DataLoader { get; set; } Gets or sets the episodic data loader for sampling tasks.
IFullModel<T, TInput, TOutput> MetaModel { get; set; } Gets or sets the meta-model (feature encoder) to be trained.
IGradientBasedOptimizer<T, TInput, TOutput> MetaOptimizer { get; set; } Optimizer for the meta-update.
ILossFunction<T> LossFunction { get; set; } Loss function for meta-training; null uses cross-entropy over logits.
ProtoNetsDistanceFunction DistanceFunction { get; set; } Gets or sets the distance function for measuring similarity between embeddings.
bool EnableCheckpointing { get; set; } Gets or sets whether to save model checkpoints.
bool NormalizeFeatures { get; set; } Gets or sets whether to L2-normalize feature embeddings.
bool UseAdaptiveClassScaling { get; set; } Gets or sets whether to learn a positive distance scale per class slot.
bool UseAttentionMechanism { get; set; } Gets or sets whether to weight each support example in its class prototype by learned attention.
bool UseFirstOrder { get; set; } Gets or sets whether to use first-order approximation.
double InnerLearningRate { get; set; } Gets or sets the learning rate for the inner loop (task adaptation).
double MahalanobisScaling { get; set; } Gets or sets the initial scale of the learned Mahalanobis metric.
double OuterLearningRate { get; set; } Gets or sets the learning rate for the outer loop (encoder training).
double Temperature { get; set; } Gets or sets the temperature for softmax scaling.
double? GradientClipThreshold { get; set; } Gets or sets the maximum gradient norm for gradient clipping.
int AdaptationSteps { get; set; } Gets or sets the number of adaptation steps.
int CheckpointFrequency { get; set; } Gets or sets how often to save checkpoints.
int EvaluationFrequency { get; set; } Gets or sets how often to evaluate the meta-learner.
int EvaluationTasks { get; set; } Gets or sets the number of tasks to use for evaluation.
int MetaBatchSize { get; set; } Gets or sets the number of tasks to sample per meta-training iteration.
int NumMetaIterations { get; set; } Gets or sets the total number of meta-training iterations.
int? RandomSeed { get; set; } Gets or sets the random seed for reproducibility.

Methods

Method Summary
IMetaLearnerOptions<T> Clone() Creates a deep copy of the ProtoNets options.
bool IsValid() Validates that all ProtoNets configuration options are properly set.