BOILOptions<T, TInput, TOutput>

Options & Configuration · AiDotNet.MetaLearning.Options

Configuration options for Body Only Inner Loop (BOIL) algorithm.

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

Implements: IMetaLearnerOptions<T>

For Beginners

BOIL splits a neural network into two parts:

How It Works

BOIL is the opposite of ANIL - it only adapts the feature extractor (body) during inner-loop adaptation while keeping the classification head frozen. This explores the hypothesis that task-specific features are more important than task-specific classifiers.

This is the opposite of ANIL (which freezes body, adapts head). BOIL tests whether it’s better to adapt HOW we see things rather than HOW we decide.

When to use BOIL:

  • When tasks differ more in their visual/input patterns than their decision boundaries
  • When you have a good meta-learned classifier that works across tasks
  • When you want to experiment with different adaptation strategies

Reference: Oh, J., Yoo, H., Kim, C., & Yun, S. Y. (2021). BOIL: Towards Representation Change for Few-shot Learning.

Constructors

Constructor Summary
BOILOptions(IFullModel<T, TInput, TOutput> metaModel) Initializes a new instance of the BOILOptions 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 cross-entropy over logits.
bool EnableCheckpointing { get; set; } Gets or sets whether to save model checkpoints.
bool UseFirstOrder { get; set; } Gets or sets whether to drop the second-order terms of the meta-gradient.
bool UseLayerwiseLearningRates { get; set; } Gets or sets whether to meta-learn one inner learning rate per body layer and per inner step.
double BodyAdaptationFraction { get; set; } Gets or sets the fraction of the body’s layers the inner loop adapts, counted from the top.
double BodyL2Regularization { get; set; } Gets or sets the L2 regularization strength for the body.
double EarlyLayerLrMultiplier { get; set; } Gets or sets the initial scale of the learned rates in the lower half of the body’s layers.
double InnerLearningRate { get; set; } Gets or sets the learning rate for the inner loop (body 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 BOIL options.
bool IsValid() Validates that all BOIL configuration options are properly set.