FederatedExperienceReplay<T>
Models & Types · AiDotNet.FederatedLearning.ContinualLearning
Implements Federated Experience Replay for continual learning.
Inheritance: FederatedLearningComponentBase<T> → FederatedExperienceReplay<T>
Implements: IFederatedContinualLearningStrategy<T>
For Beginners
Experience replay is the simplest anti-forgetting technique: keep a small “memory” of representative examples from old tasks, and mix them in when training on new data. In federated ER, each client maintains their own replay buffer locally (no data sharing). When training on task T+1, each client trains on a mix of new task data and old examples from their buffer.
How It Works
Algorithm per client:
Reference: Federated Experience Replay for Continual FL (2023).
Constructors
| Constructor | Summary |
|---|---|
FederatedExperienceReplay(int bufferCapacity, double replayRatio, int seed) |
Creates a new Federated Experience Replay strategy. |
Properties
| Property | Summary |
|---|---|
double ReplayRatio { get; } |
Gets the replay ratio. |
int BufferCapacity { get; } |
Gets the buffer capacity. |
int BufferSize { get; } |
Gets the current buffer size. |
Methods
| Method | Summary |
|---|---|
List<ValueTuple<T[], int>> SampleReplay(int batchSize) |
Samples a batch from the replay buffer. |
T ComputeRegularizationPenalty(Vector<T> currentParameters, Vector<T> referenceParameters, Vector<T> importanceWeights, double regularizationStrength) |
|
Vector<T> AggregateImportance(Dictionary<int, Vector<T>> clientImportances, Dictionary<int, double> clientWeights) |
|
Vector<T> ComputeImportance(Vector<T> modelParameters, Matrix<T> taskData) |
|
Vector<T> ProjectGradient(Vector<T> gradient, Vector<T> importanceWeights) |
|
void AddToBuffer(T[] features, int label) |
Adds an example to the replay buffer using reservoir sampling. |