ANILOptions<T, TInput, TOutput>
Options & Configuration · AiDotNet.MetaLearning.Options
Configuration options for Almost No Inner Loop (ANIL) algorithm.
Inheritance: ModelOptions → ANILOptions<T, TInput, TOutput>
Implements: IMetaLearnerOptions<T>
For Beginners
ANIL splits a neural network into two parts:
- Body (Feature Extractor): Learns general features shared across tasks (FROZEN during adaptation)
- Head (Classifier): Task-specific layer that is adapted for each new task
Key insight: Most of the “learning to learn” happens in the feature extractor, which doesn’t need to be adapted per-task. Only the small classifier head needs to change for each new task.
Benefits:
- Much faster than MAML (fewer parameters to adapt)
- Less memory usage (no need to store gradients for body)
- Often performs as well as full MAML
How It Works
ANIL is a simplified version of MAML that only adapts the classification head during inner-loop adaptation, while keeping the feature extractor frozen. This significantly reduces computation while maintaining competitive performance.
Constructors
| Constructor | Summary |
|---|---|
ANILOptions(IFullModel<T, TInput, TOutput> metaModel) |
Initializes a new instance of the ANILOptions 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; } |
Optimizer for task adaptation. |
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. |
bool EnableCheckpointing { get; set; } |
Gets or sets whether to save model checkpoints. |
bool ReinitializeHead { get; set; } |
Gets or sets whether to reinitialize the head for each task. |
bool UseFirstOrder { get; set; } |
Gets or sets whether to drop the second-order terms of the meta-gradient. |
bool UseHeadBias { get; set; } |
Gets or sets whether to use a bias term in the classification head. |
double HeadL2Regularization { get; set; } |
Gets or sets the L2 regularization strength for the head. |
double InnerLearningRate { get; set; } |
Gets or sets the learning rate for the inner loop (head adaptation). |
double OuterLearningRate { get; set; } |
Gets or sets the learning rate for the outer loop (meta-update). |
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 (gradient steps on support set). |
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 FeatureDimension { get; set; } |
Gets or sets the width of each example’s representation the head reads: the body’s per-example output width. |
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? RandomSeed { get; set; } |
Gets or sets the random seed for reproducibility. |
Methods
| Method | Summary |
|---|---|
IMetaLearnerOptions<T> Clone() |
Creates a deep copy of the ANIL options. |
bool IsValid() |
Validates that all ANIL configuration options are properly set. |