BOILAlgorithm<T, TInput, TOutput>
Models & Types · AiDotNet.MetaLearning.Algorithms
Implementation of BOIL (Body Only update in Inner Loop) meta-learning algorithm.
Inheritance: ModelBase<T, TInput, TOutput> → MetaLearnerBase<T, TInput, TOutput> → BOILAlgorithm<T, TInput, TOutput>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
BOIL keeps the “decision maker” (the head) fixed while it adapts to a new task and re-tunes the “feature extractor” (the body) instead, so each task teaches the model new ways of looking at its inputs.
How It Works
BOIL (Oh et al., ICLR 2021) is ANIL’s mirror image: each task adapts only the body - the meta-model, which embeds every example - while the head (the final linear classifier) stays frozen in the inner loop. “MAML usually sets alpha = alpha_b = alpha_h (!= 0), ANIL sets alpha_b = 0 and alpha_h != 0, and BOIL sets alpha_b != 0 and alpha_h = 0” (Sec. 3.2); the outer loop meta-updates body and head together. The frozen head forces representation change: to solve a new task the body must move the features, not the head the decision boundary.
Per example, exact. The body embeds each row into a FeatureDimension-wide representation and the head scores each row. The inner loop steps the body on the support loss through the frozen head; the outer loop differentiates the query loss through every inner step - body Hessian-vector products, and the head’s cross term through each step’s support gradient - taken as central differences of gradients, two evaluations per step. UseFirstOrder drops the second-order terms.
Beyond the paper, off by default.BodyAdaptationFraction
adapts only the top fraction of the body’s layers - BOIL’s own analysis finds representation change in the
high-level body and reuse in the low and middle layers. UseLayerwiseLearningRates
meta-learns one inner learning rate per body layer and per inner step, MAML++’s LSLR (Antoniou et al. 2019),
on the same exact meta-gradient.
Constructors
| Constructor | Summary |
|---|---|
BOILAlgorithm(BOILOptions<T, TInput, TOutput> options) |
Initializes a new instance of the BOILAlgorithm class. |
Properties
| Property | Summary |
|---|---|
MetaLearningAlgorithmType AlgorithmType { get; } |
Methods
| Method | Summary |
|---|---|
IModel<TInput, TOutput, ModelMetadata<T>> Adapt(IMetaLearningTask<T, TInput, TOutput> task) |
Adapts the meta-learned model to a new task by only updating the body. |
T MetaTrain(TaskBatch<T, TInput, TOutput> taskBatch) |
Performs one meta-training step: body-only adaptation per task, then one update of the body, the head and (when learned) the per-layer rates from the query losses. |