WarpGradOptions<T, TInput, TOutput>

Options & Configuration · AiDotNet.MetaLearning.Options

Configuration options for the WarpGrad (Warped Gradient Descent) meta-learning algorithm.

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

Implements: IMetaLearnerOptions<T>

For Beginners

WarpGrad is like learning a better map for navigating a landscape.

Imagine you’re trying to reach the bottom of a valley (optimal solution):

  • Standard gradient descent: Walk straight downhill (may zigzag on narrow valleys)
  • MAML: Start from a better position on the hillside
  • WarpGrad: Learn to reshape the landscape so downhill is always the right direction

The “warp layers” transform the gradients (direction signals) so that even simple gradient descent moves efficiently toward the solution. This is like giving the model a compass that’s been calibrated for different types of tasks.

Key advantages over MAML:

  • No need to backpropagate through the inner loop (much cheaper)
  • Warp layers provide task-independent gradient conditioning
  • Can be combined with any inner-loop optimizer

How It Works

WarpGrad learns a preconditioning matrix (warp-layers) that transforms gradients during inner-loop adaptation. Unlike MAML which learns a good initialization, WarpGrad learns a good gradient descent geometry that makes adaptation more efficient.

Reference: Flennerhag, S., Rusu, A. A., Pascanu, R., Visin, F., Yin, H., & Hadsell, R. (2020). Meta-Learning with Warped Gradient Descent. ICLR 2020.

Constructors

Constructor Summary
WarpGradOptions(IFullModel<T, TInput, TOutput> metaModel) Initializes a new instance of the WarpGradOptions 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 to be trained.
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; } Gets or sets whether to save model checkpoints.
bool UseDiagonalWarp { get; set; } Gets or sets whether warp-layers use diagonal (element-wise) or full matrix transformations.
bool UseFirstOrder { get; set; } Gets or sets whether to use first-order approximation for meta-gradients.
double InnerLearningRate { get; set; } Gets or sets the learning rate for the inner loop (task-specific adaptation).
double OuterLearningRate { get; set; } Gets or sets the learning rate for the outer loop (meta-parameter and warp-layer updates).
double WarpInitScale { get; set; } Gets or sets the initialization scale for warp-layer parameters.
double WarpLearningRate { get; set; } Gets or sets the learning rate for warp-layer parameter updates.
double WarpRegularization { get; set; } Gets or sets the L2 regularization weight for warp-layer parameters.
double? GradientClipThreshold { get; set; } Gets or sets the maximum gradient norm for gradient clipping.
int AdaptationSteps { get; set; } Gets or sets the number of gradient steps for inner loop adaptation.
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 NumWarpLayers { get; set; } Gets or sets the number of warp-layers to interleave with the task learner.
int WarpLayerHiddenDim { get; set; } Gets or sets the hidden dimension for warp-layer MLPs.
int? RandomSeed { get; set; } Gets or sets the random seed for reproducibility.

Methods

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