AveragedGEM<T>

Models & Types · AiDotNet.ContinualLearning

Implements Averaged Gradient Episodic Memory (A-GEM) for continual learning.

Implements: IContinualLearningStrategy<T>

For Beginners

A-GEM is a more efficient version of GEM that uses a single random sample from the episodic memory instead of checking constraints against all stored examples. This makes it much faster while maintaining similar performance.

How It Works

How it works:

Key Difference from GEM:

Projection Formula:

If g · g_ref < 0: g_proj = g - (g · g_ref / g_ref · g_ref) × g_ref

Reference: Chaudhry, A. et al. “Efficient Lifelong Learning with A-GEM” (2019). ICLR.

Constructors

Constructor Summary
AveragedGEM(int memorySize, int sampleSize, double lambda, int? seed) Initializes a new instance of the AveragedGEM class.

Properties

Property Summary
bool AccumulatesAcrossTasks { get; }
double Lambda { get; set; }
int TaskCount { get; } Gets the number of tasks stored in episodic memory.
int TotalMemorySize { get; } Gets the total number of samples in episodic memory.

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()