Table of Contents

Class MetaLearnerOptionsBase<T>

Namespace
AiDotNet.MetaLearning
Assembly
AiDotNet.dll

Base implementation of IMetaLearnerOptions with industry-standard defaults.

public class MetaLearnerOptionsBase<T> : IMetaLearnerOptions<T>

Type Parameters

T

The numeric type (e.g., float, double).

Inheritance
MetaLearnerOptionsBase<T>
Implements
Inherited Members

Remarks

This class provides sensible defaults for meta-learning configurations based on established practices from the meta-learning literature (MAML, Reptile, etc.).

For Beginners: You can use this class directly or extend it to create algorithm-specific options classes. The defaults work well for most scenarios.

Constructors

MetaLearnerOptionsBase()

Initializes a new instance with default values.

public MetaLearnerOptionsBase()

MetaLearnerOptionsBase(IMetaLearnerOptions<T>)

Initializes a new instance by copying values from another options instance.

protected MetaLearnerOptionsBase(IMetaLearnerOptions<T> other)

Parameters

other IMetaLearnerOptions<T>

The options instance to copy from.

Properties

AdaptationSteps

Gets the number of gradient descent steps for inner loop adaptation.

public int AdaptationSteps { get; set; }

Property Value

int

How many times to update parameters on each task's support set. Typical values: 1 to 10. Default: 5

Remarks

Default: 5 (balanced between 1-step and 10-step adaptation)

CheckpointFrequency

Gets the checkpoint save frequency in meta-iterations.

public int CheckpointFrequency { get; set; }

Property Value

int

Save checkpoint every N meta-iterations. Only used if EnableCheckpointing is true. Default: 500

Remarks

Default: 500 (save every 500 iterations)

EnableCheckpointing

Gets whether to save checkpoints during training.

public bool EnableCheckpointing { get; set; }

Property Value

bool

True to save model checkpoints periodically.

Remarks

Default: true (save progress during training)

EvaluationFrequency

Gets the evaluation frequency in meta-iterations.

public int EvaluationFrequency { get; set; }

Property Value

int

Run evaluation every N meta-iterations. Set to 0 to disable periodic evaluation. Default: 100

Remarks

Default: 100 (evaluate every 100 iterations)

EvaluationTasks

Gets the number of evaluation tasks for periodic validation.

public int EvaluationTasks { get; set; }

Property Value

int

How many tasks to use when evaluating model performance. Typical values: 100 to 1000. Default: 100

Remarks

Default: 100 (quick evaluation during training)

GradientClipThreshold

Gets the gradient clipping threshold to prevent exploding gradients.

public double? GradientClipThreshold { get; set; }

Property Value

double?

Maximum gradient norm. Set to null or 0 to disable clipping. Typical values: 1.0 to 10.0. Default: 10.0

Remarks

Default: 10.0 (prevents gradient explosion)

InnerLearningRate

Gets the inner loop learning rate for task-specific adaptation.

public double InnerLearningRate { get; set; }

Property Value

double

The learning rate used during task adaptation on support sets. Typical values: 0.001 to 0.1. Default: 0.01

Remarks

Default: 0.01 (standard for MAML-like algorithms)

MetaBatchSize

Gets the number of tasks to sample per meta-update (meta-batch size).

public int MetaBatchSize { get; set; }

Property Value

int

How many tasks to average over for each outer loop update. Typical values: 1 (online) to 32 (batch). Default: 4

Remarks

For Beginners: This controls how many tasks you learn from before updating your meta-parameters: - MetaBatchSize = 1: Update after every task (more noisy, faster iteration) - MetaBatchSize = 16: Update after 16 tasks (more stable, slower iteration)

NumMetaIterations

Gets the number of meta-training iterations to perform.

public int NumMetaIterations { get; set; }

Property Value

int

How many times to perform the outer loop meta-update. Typical values: 100 to 10,000. Default: 1000

Remarks

Default: 1000 (reasonable for initial training runs)

OuterLearningRate

Gets the outer loop learning rate for meta-optimization.

public double OuterLearningRate { get; set; }

Property Value

double

The learning rate for updating meta-parameters. Typically 10x smaller than InnerLearningRate. Typical values: 0.0001 to 0.01. Default: 0.001

Remarks

Default: 0.001 (typically 10x smaller than inner rate)

RandomSeed

Gets the random seed for reproducible task sampling and initialization.

public int? RandomSeed { get; set; }

Property Value

int?

Random seed value. Set to null for non-deterministic behavior.

Remarks

Default: null (non-deterministic for variety in training)

UseFirstOrder

Gets whether to use first-order approximation (e.g., FOMAML, Reptile).

public bool UseFirstOrder { get; set; }

Property Value

bool

True to ignore second-order gradients, which is faster but may be less accurate. Default: false for MAML-based algorithms.

Remarks

For Beginners: First-order approximation: - True: Faster training, simpler gradients, works well in practice - False: More accurate gradients, slower, may be unstable with many inner steps

Methods

Clone()

Creates a deep copy of this options instance.

public virtual IMetaLearnerOptions<T> Clone()

Returns

IMetaLearnerOptions<T>

A new options instance with the same values.

CreateBuilder()

Creates a builder for fluent configuration.

public static MetaLearnerOptionsBuilder<T> CreateBuilder()

Returns

MetaLearnerOptionsBuilder<T>

A new builder instance.

IsValid()

Validates that the configuration is valid and sensible.

public virtual bool IsValid()

Returns

bool

True if the configuration is valid; false otherwise.