AdaptedMetaModel<T, TInput, TOutput>
Models & Types · AiDotNet.MetaLearning.Algorithms
Generic adapted model wrapper for meta-learning algorithms that use gradient-based inner-loop adaptation. After adaptation, the model uses the adapted parameters for prediction.
Inheritance: ModelWrapperBase<T, TInput, TOutput> → MetaLearningModelBase<T, TInput, TOutput> → AdaptedMetaModel<T, TInput, TOutput>
Implements: IAdaptedMetaModel<T>
For Beginners
An adapted meta-model is the result of a meta-learning algorithm (like MAML) adapting to a new task. After seeing a few examples of a new task, the meta-learner produces this adapted model with task-specific parameters. Think of it like a student who has learned general problem-solving skills and then quickly adapts to a specific exam topic after seeing just a few practice questions.
Example
var baseModel = new NeuralNetwork<float>(
new NeuralNetworkArchitecture<float>(inputFeatures: 8, outputSize: 4));
// The parameters MAML's inner loop produced for one task.
var adaptedParams = new Vector<float>(baseModel.GetParameters().Length);
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 4);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
.ConfigureModel(new AdaptedMetaModel<float, Tensor<float>, Tensor<float>>(baseModel, adaptedParams))
.Build(trainX, trainY);
var queryInput = Tensor<float>.CreateRandom(1, 8);
Tensor<float> prediction = result.Predict(queryInput);
Constructors
| Constructor | Summary |
|---|---|
AdaptedMetaModel(IFullModel<T, TInput, TOutput> model, Vector<T> adaptedParams, Vector<T> supportFeatures, Vector<T> modulationFactors) |
Properties
| Property | Summary |
|---|---|
Vector<T> AdaptedSupportFeatures { get; } |
|
Vector<T> ParameterModulationFactors { get; } |
Methods
| Method | Summary |
|---|---|
IFullModel<T, TInput, TOutput> WithParameters(Vector<T> parameters) |
|
TOutput Predict(TInput input) |