IContinualLearner<T, TInput, TOutput>
Interfaces · AiDotNet.ContinualLearning.Interfaces
Interface for continual learning trainers that can learn multiple tasks sequentially.
Known implementations: ContinualLearnerBase<T, TInput, TOutput>
For Beginners
Continual learning (also called lifelong learning) is the ability to learn new tasks over time without forgetting previously learned knowledge. Traditional neural networks suffer from “catastrophic forgetting” - when trained on new data, they forget what they learned before.
How It Works
This interface provides methods to:
- Learn new tasks while protecting old knowledge
- Evaluate performance on all learned tasks
- Save and load model state for resuming training
Common Implementations:
- EWCTrainer: Uses Elastic Weight Consolidation to protect important weights
- LwFTrainer: Uses Learning without Forgetting with knowledge distillation
- GEMTrainer: Uses Gradient Episodic Memory to constrain gradients
References:
- Parisi et al. “Continual Lifelong Learning with Neural Networks: A Review” (2019)
- De Lange et al. “A Continual Learning Survey” (2021)
Properties
| Property | Summary |
|---|---|
IContinualLearnerConfig<T> Config { get; } |
Gets the configuration for the continual learner. |
IFullModel<T, TInput, TOutput> BaseModel { get; } |
Gets the underlying model being trained. |
bool IsTraining { get; } |
Gets whether the learner is currently training. |
int TasksLearned { get; } |
Gets the number of tasks that have been learned. |
long MemoryUsageBytes { get; } |
Gets the current memory usage of the learner in bytes. |
Methods
| Method | Summary |
|---|---|
ContinualEvaluationResult<T> EvaluateAllTasks() |
Evaluates the model on all learned tasks. |
ContinualLearningResult<T> GetTaskHistory(int taskId) |
Gets the training history for a specific task. |
ContinualLearningResult<T> LearnTask(IDataset<T, TInput, TOutput> taskData) |
Learns a new task from the provided data. |
ContinualLearningResult<T> LearnTask(IDataset<T, TInput, TOutput> taskData, IDataset<T, TInput, TOutput> validationData, int? earlyStoppingPatience) |
Learns a new task with a validation set for early stopping and monitoring. |
IReadOnlyDictionary<int, T> ComputeForgetting() |
Computes the current forgetting metric for all tasks. |
IReadOnlyList<ContinualLearningResult<T>> GetAllHistory() |
Gets all training history. |
TaskEvaluationResult<T> EvaluateTask(int taskId, IDataset<T, TInput, TOutput> testData) |
Evaluates the model on a specific task. |
void Load(string path) |
Loads the learner state from a file. |
void Reset() |
Resets the learner to its initial state. |
void Save(string path) |
Saves the learner state to a file. |