MetaLearnerBase<T, TInput, TOutput>

Base Classes · AiDotNet.MetaLearning

Unified base class for all meta-learning algorithms, providing both training infrastructure and shared algorithm utilities.

Inheritance: ModelBase<T, TInput, TOutput> → MetaLearnerBase<T, TInput, TOutput>

Implements: IMetaLearner<T, TInput, TOutput>

Known derived types: ACLAlgorithm<T, TInput, TOutput>, ANILAlgorithm<T, TInput, TOutput>, ATAMLAlgorithm<T, TInput, TOutput>, AWGIMAlgorithm<T, TInput, TOutput>, ActiveTransFSLAlgorithm<T, TInput, TOutput>, AutoLoRAAlgorithm<T, TInput, TOutput>, BMAMLAlgorithm<T, TInput, TOutput>, BOILAlgorithm<T, TInput, TOutput>, BayProNetAlgorithm<T, TInput, TOutput>, BayTransProtoAlgorithm<T, TInput, TOutput>, CAMLAlgorithm<T, TInput, TOutput>, CAVIAAlgorithm<T, TInput, TOutput>, CNAPAlgorithm<T, TInput, TOutput>, ConstellationNetAlgorithm<T, TInput, TOutput>, ContextMetaRLAlgorithm<T, TInput, TOutput>, DKTAlgorithm<T, TInput, TOutput>, DPGNAlgorithm<T, TInput, TOutput>, DREAMAlgorithm<T, TInput, TOutput>, DeepEMDAlgorithm<T, TInput, TOutput>, DiscoRLAlgorithm<T, TInput, TOutput>, DynamicTaskSamplingAlgorithm<T, TInput, TOutput>, EPNetAlgorithm<T, TInput, TOutput>, ETPNAlgorithm<T, TInput, TOutput>, FEATAlgorithm<T, TInput, TOutput>, FRNAlgorithm<T, TInput, TOutput>, FewTUREAlgorithm<T, TInput, TOutput>, FreqPriorAlgorithm<T, TInput, TOutput>, FreqPromptAlgorithm<T, TInput, TOutput>, GNNMetaAlgorithm<T, TInput, TOutput>, HyperCLIPAlgorithm<T, TInput, TOutput>, HyperMAMLAlgorithm<T, TInput, TOutput>, HyperNeRFMetaAlgorithm<T, TInput, TOutput>, HyperNetMetaRLAlgorithm<T, TInput, TOutput>, HyperShotAlgorithm<T, TInput, TOutput>, ICMFusionAlgorithm<T, TInput, TOutput>, InContextRLAlgorithm<T, TInput, TOutput>, JMPAlgorithm<T, TInput, TOutput>, LEOAlgorithm<T, TInput, TOutput>, LFTAlgorithm<T, TInput, TOutput>, LaplacianShotAlgorithm<T, TInput, TOutput>, LoRARecycleAlgorithm<T, TInput, TOutput>, MAMLAlgorithm<T, TInput, TOutput>, MAMLPlusPlusAlgorithm<T, TInput, TOutput>, MANNAlgorithm<T, TInput, TOutput>, MCLAlgorithm<T, TInput, TOutput>, MOCAAlgorithm<T, TInput, TOutput>, MPTSAlgorithm<T, TInput, TOutput>, MatchingNetworksAlgorithm<T, TInput, TOutput>, MbPAAlgorithm<T, TInput, TOutput>, MetaBaselineAlgorithm<T, TInput, TOutput>, MetaCollaborativeAlgorithm<T, TInput, TOutput>, MetaDDPMAlgorithm<T, TInput, TOutput>, MetaDMAlgorithm<T, TInput, TOutput>, MetaDiffAlgorithm<T, TInput, TOutput>, MetaFDMixupAlgorithm<T, TInput, TOutput>, MetaLoRAAlgorithm<T, TInput, TOutput>, MetaLoRABankAlgorithm<T, TInput, TOutput>, MetaOptNetAlgorithm<T, TInput, TOutput>, MetaPACOHAlgorithm<T, TInput, TOutput>, MetaSGDAlgorithm<T, TInput, TOutput> (+32 more)

How It Works

This base class follows the TimeSeriesModelBase pattern where the base class does heavy lifting and concrete algorithm implementations override with their custom logic. It provides:

For Algorithm Implementers: To create a new meta-learning algorithm:

  1. Extend this base class
  2. Set AlgorithmType in constructor
  3. Override MetaTrainCore() with your algorithm’s meta-update logic
  4. Override AdaptCore() with your task adaptation strategy
  5. All shared functionality (metrics, saving, evaluation) is handled automatically

Properties

Property Summary
IFullModel<T, TInput, TOutput> BaseModel { get; }
ILossFunction<T> DefaultLossFunction { get; }
IMetaLearnerOptions<T> Options { get; }
MetaLearningAlgorithmType AlgorithmType { get; }
double InnerLearningRate { get; }
double OuterLearningRate { get; }
int AdaptationSteps { get; }
int CurrentIteration { get; }

Methods

Method Summary
IFullModel<T, TInput, TOutput> DeepCopy()
IFullModel<T, TInput, TOutput> GetMetaModel()
IFullModel<T, TInput, TOutput> WithParameters(Vector<T> parameters)
IModel<TInput, TOutput, ModelMetadata<T>> Adapt(IMetaLearningTask<T, TInput, TOutput> task)
MetaAdaptationResult<T> AdaptAndEvaluate(MetaLearningTask<T, TInput, TOutput> task)
MetaEvaluationResult<T> Evaluate(int numTasks)
MetaTrainingResult<T> Train()
MetaTrainingStepResult<T> MetaTrainStep(ITaskSampler<T, TInput, TOutput> sampler, int batchSize) Performs a single meta-training step using a task sampler.
MetaTrainingStepResult<T> MetaTrainStep(int batchSize)
ModelOptions GetOptions()
T Evaluate(TaskBatch<T, TInput, TOutput> taskBatch)
T MetaTrain(TaskBatch<T, TInput, TOutput> taskBatch)
TOutput Predict(TInput input) Predicts output by delegating to the meta-trained base model.
void Load(string filePath)
void Reset()
void Save(string filePath)
void SetMetaModel(IFullModel<T, TInput, TOutput> model)
void Train(TInput input, TOutput expectedOutput) Trains the meta-learner on a single input-output pair.