LaplacianShotOptions<T, TInput, TOutput>

Options & Configuration · AiDotNet.MetaLearning.Options

Configuration options for LaplacianShot (Ziko et al., ICML 2020) few-shot learning.

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

Implements: IMetaLearnerOptions<T>

For Beginners

LaplacianShot is like “asking your neighbors for help”:

The idea:

  1. Start with nearest-centroid classification (like SimpleShot)
  2. Build a graph connecting similar query examples
  3. Propagate labels through the graph: if your neighbors are confident about class A,

you should also lean toward class A

Analogy: Imagine voting in a room full of people:

  • First, everyone votes independently based on what they see
  • Then, people discuss with their nearest neighbors
  • After discussion, everyone updates their vote
  • The final votes are more accurate because neighbors share information

Why Laplacian? The “Laplacian” is a mathematical way to encode graph smoothness. Laplacian regularization says: “predictions should be smooth over the graph” meaning similar examples should have similar predictions.

How It Works

LaplacianShot extends nearest-centroid classification with Laplacian regularization over the query set’s feature graph. It encourages nearby query examples (in feature space) to receive similar class assignments, propagating confident predictions to uncertain ones.

Reference: Ziko, I., Dolz, J., Granger, E., & Ben Ayed, I. (2020). Laplacian Regularized Few-Shot Learning. ICML 2020.

Constructors

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

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 KernelBandwidth { get; set; } Gets or sets the kernel bandwidth for computing graph edge weights.
double LaplacianWeight { get; set; } Gets or sets the Laplacian regularization weight.
double OuterLearningRate { get; set; }
double StepSize { get; set; } Gets or sets the step size (alpha) for Laplacian smoothing iterations.
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 KNearestNeighbors { get; set; } Gets or sets the number of nearest neighbors for building the kNN graph.
int MetaBatchSize { get; set; }
int NumMetaIterations { get; set; }
int PropagationIterations { get; set; } Gets or sets the number of label propagation iterations.
int? RandomSeed { get; set; } Gets or sets the random seed.

Methods

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