DeepEMDOptions<T, TInput, TOutput>

Options & Configuration · AiDotNet.MetaLearning.Options

Configuration options for DeepEMD (Zhang et al., CVPR 2020) few-shot learning.

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

Implements: IMetaLearnerOptions<T>

For Beginners

DeepEMD uses a clever way to compare examples:

The Problem with simple metrics: ProtoNets averages all features into one vector. This loses local details like “the left part of image A looks like the right part of image B.”

DeepEMD’s solution: Earth Mover’s Distance Think of features as piles of dirt. EMD measures the minimum “work” needed to reshape one pile into another. This captures structural alignment:

  • Each local feature (patch) from one image can match any patch from another
  • The cost of matching = distance between the patches
  • EMD finds the optimal matching that minimizes total distance

Three modes:

  • FCN: Feature maps from the last conv layer (spatial patches)
  • Grid: Divide feature maps into a regular grid
  • Sampling: Sample representative local features

How It Works

DeepEMD uses the Earth Mover’s Distance (optimal transport) as a metric for comparing image representations in few-shot learning. Unlike ProtoNets which compares single vectors, DeepEMD compares sets of local features using optimal transport, capturing fine-grained structural similarity.

Reference: Zhang, C., Cai, Y., Lin, G., & Shen, C. (2020). DeepEMD: Few-Shot Image Classification with Differentiable Earth Mover’s Distance and Structured Classifiers. CVPR 2020.

Constructors

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

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; } Not used by DeepEMD: its adaptation takes no gradient steps (see AdaptationSteps).
double OuterLearningRate { get; set; }
double SinkhornRegularization { get; set; } Gets or sets the regularization parameter for Sinkhorn algorithm.
double Temperature { get; set; } Gets or sets the temperature for the EMD-based classification logits.
double? GradientClipThreshold { get; set; }
int AdaptationSteps { get; set; } Number of gradient steps taken on each task’s support set.
int CheckpointFrequency { get; set; }
int EvaluationFrequency { get; set; }
int EvaluationTasks { get; set; }
int MetaBatchSize { get; set; }
int NumMetaIterations { get; set; }
int NumNodes { get; set; } Gets or sets the number of local features (nodes) per example for EMD computation.
int SinkhornIterations { get; set; } Gets or sets the number of Sinkhorn iterations for approximate EMD.
int? RandomSeed { get; set; } Gets or sets the random seed.
string EMDMode { get; set; } Gets or sets the EMD mode: “fcn”, “grid”, or “sampling”.

Methods

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