NeuralProcessModel<T, TInput, TOutput>
Models & Types · AiDotNet.MetaLearning.Algorithms
Adapted model for Neural Process family algorithms.
Inheritance: ModelWrapperBase<T, TInput, TOutput> → MetaLearningModelBase<T, TInput, TOutput> → NeuralProcessModel<T, TInput, TOutput>
Implements: IAdaptedMetaModel<T>
For Beginners
This is the output of a Neural Process after it has seen some context examples. It stores the aggregated representation of what the model learned from those examples and uses it to make predictions at new target points. Unlike gradient-based approaches, adaptation happens in a single forward pass.
Example
var baseModel = new SimpleRegression<float>();
var parameters = new Vector<float>((int)baseModel.ParameterCount);
// the context examples, encoded and aggregated into one representation
var aggregatedRepresentation = new Vector<float>(new float[] { 0.2f, -0.1f, 0.4f });
var targetInputs = new Matrix<float>(new float[,] { { 1.0f, 2.0f }, { 3.0f, 4.0f } });
var targetOutputs = new Vector<float>(new float[] { 3.1f, 7.2f });
var result = new AiModelBuilder<float, Matrix<float>, Vector<float>>()
.ConfigureModel(new NeuralProcessModel<float, Matrix<float>, Vector<float>>(
baseModel, parameters, aggregatedRepresentation))
.Build(targetInputs, targetOutputs);
Vector<float> prediction = result.Predict(targetInputs);
Constructors
| Constructor | Summary |
|---|---|
NeuralProcessModel(IFullModel<T, TInput, TOutput> model, Vector<T> parameters, Vector<T> contextRepresentation) |
Initializes the adapted model from the meta-model and the parameters conditioned on the context set. |
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) |