MatchingNetworksOptions<T, TInput, TOutput>

Options & Configuration · AiDotNet.MetaLearning.Options

Configuration options for Matching Networks algorithm.

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

Implements: IMetaLearnerOptions<T>

For Beginners

Matching Networks learn to pay attention to similar examples:

  1. Encode all examples (support and query) with a shared encoder
  2. For each query, compute attention weights with all support examples
  3. Use similarity (cosine, dot product, etc.) for weights
  4. Predict weighted sum of support labels (soft nearest neighbor)

Unlike ProtoNets which uses class prototypes, Matching Networks consider every support example individually.

How It Works

Matching Networks use attention mechanisms over the support set to classify query examples. It computes a weighted sum of support labels where weights are determined by an attention function that measures similarity between examples.

Constructors

Constructor Summary
MatchingNetworksOptions(IFullModel<T, TInput, TOutput> metaModel) Initializes a new instance of the MatchingNetworksOptions 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 (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.
MatchingNetworksAttentionFunction AttentionFunction { get; set; } Gets or sets the attention function for computing similarity.
bool EnableCheckpointing { get; set; } Gets or sets whether to save model checkpoints.
bool UseBidirectionalEncoding { get; set; } Gets or sets whether to embed the support set in context with a bidirectional LSTM.
bool UseFirstOrder { get; set; } Gets or sets whether to use first-order approximation.
bool UseFullContextEmbedding { get; set; } Gets or sets whether to use the paper’s full context embeddings for both the support set and the queries.
double InnerLearningRate { get; set; } Gets or sets the learning rate for the inner loop (not used in Matching Networks).
double L2Regularization { get; set; } Gets or sets the L2 regularization strength.
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 attention.
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 NumClasses { get; set; } Gets or sets the number of output classes.
int NumMetaIterations { get; set; } Gets or sets the total number of meta-training iterations.
int ProcessingSteps { get; set; } Gets or sets K, the number of attention read steps of the query context embedding.
int? RandomSeed { get; set; } Gets or sets the random seed for reproducibility.

Methods

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