GenerativeReplay<T>
Models & Types · AiDotNet.ContinualLearning
Implements Generative Replay (also known as Deep Generative Replay) for continual learning.
Implements: IContinualLearningStrategy<T>
For Beginners
Generative Replay uses a generative model (like a VAE or GAN) to create pseudo-examples from previous tasks instead of storing real examples. This enables rehearsal without storing actual data, which is useful for privacy-sensitive applications or when memory is limited.
How It Works
How it works:
Key Components:
Advantages:
Reference: Shin, H., Lee, J.K., Kim, J., and Kim, J. “Continual Learning with Deep Generative Replay” (2017). NeurIPS.
Constructors
| Constructor | Summary |
|---|---|
GenerativeReplay(int replayBatchSize, double replayRatio, double lambda, int? seed) |
Initializes a new instance of the GenerativeReplay class. |
Properties
| Property | Summary |
|---|---|
bool AccumulatesAcrossTasks { get; } |
|
double Lambda { get; set; } |
|
double ReplayRatio { get; } |
Gets the replay ratio. |
int ReplayBatchSize { get; } |
Gets the replay batch size. |
int TaskCount { get; } |
Gets the number of tasks processed. |
Methods
| Method | Summary |
|---|---|
T ComputeLoss(INeuralNetwork<T> network) |
|
ValueTuple<Tensor<T>, Tensor<T>> CreateMixedBatch(Tensor<T> currentInputs, Tensor<T> currentTargets, int batchSize) |
Creates a mixed training batch combining new data with generated replay data. |
ValueTuple<Tensor<T>, Tensor<T>> GenerateReplaySamples() |
Generates pseudo-examples for replay using the generator. |
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() |
|
void SetGenerator(IGenerativeModel<T> generator) |
Sets the generative model used for replay. |