LwFTrainer<T, TInput, TOutput>

Models & Types · AiDotNet.ContinualLearning.Trainers

Continual learning trainer using Learning without Forgetting (LwF).

Inheritance: ContinualLearnerBase<T, TInput, TOutput> → LwFTrainer<T, TInput, TOutput>

For Beginners

This trainer implements continual learning using LwF, which prevents catastrophic forgetting through knowledge distillation from a “teacher” model (the model before training on the new task).

How It Works

How LwF Works:

Key Advantage: LwF doesn’t need to store old task data - it only needs the teacher model’s outputs on current task data.

Distillation Loss:

Where T is the temperature parameter.

Usage Example:

Reference: Li and Hoiem “Learning without Forgetting” (2017)

Constructors

Constructor Summary
LwFTrainer(IFullModel<T, TInput, TOutput> model, ILossFunction<T> lossFunction, IContinualLearnerConfig<T> config, IContinualLearningStrategy<T, TInput, TOutput> strategy) Initializes a new LwF trainer with default options.
LwFTrainer(IFullModel<T, TInput, TOutput> model, ILossFunction<T> lossFunction, IContinualLearnerConfig<T> config, IContinualLearningStrategy<T, TInput, TOutput> strategy, LwFTrainerOptions<T> options) Initializes a new LwF trainer with custom options.

Properties

Property Summary
LearningWithoutForgetting<T, TInput, TOutput> LwFStrategy { get; } Gets the LwF-specific strategy if available.