OnlineEWC<T>

Models & Types · AiDotNet.ContinualLearning

Implements Online Elastic Weight Consolidation (Online EWC) for continual learning.

Implements: IContinualLearningStrategy<T>

For Beginners

Online EWC is a memory-efficient variant of EWC that maintains a single running approximation of the Fisher Information Matrix across all tasks, rather than storing separate matrices for each task.

How It Works

How it works:

Formula:

F̃ = γ * F_old + F_new

θ̃* = (γ * F_old * θ*_old + F_new * θ_new) / (γ * F_old + F_new)

Advantages:

Reference: Schwarz, J. et al. “Progress & Compress: A scalable framework for continual learning” (2018). ICML.

Constructors

Constructor Summary
OnlineEWC(double lambda, double gamma) Initializes a new instance of the OnlineEWC class.

Properties

Property Summary
bool AccumulatesAcrossTasks { get; }
double Gamma { get; } Gets the decay factor for old Fisher information.
double Lambda { get; set; }
int TaskCount { get; } Gets the number of tasks processed.

Methods

Method Summary
T ComputeLoss(INeuralNetwork<T> network)
Vector<T> ModifyGradients(INeuralNetwork<T> network, Vector<T> gradients)
void AfterTask(INeuralNetwork<T> network, ValueTuple<Tensor<T>, Tensor<T>> taskData, int taskId)
void BeforeTask(INeuralNetwork<T> network, int taskId)
void Reset()