Table of Contents

Class ContinualLearningOptions

Namespace
AiDotNet.Models.Options
Assembly
AiDotNet.dll

Represents configuration options for continual learning.

public class ContinualLearningOptions
Inheritance
ContinualLearningOptions
Inherited Members

Remarks

For Beginners: Continual learning (also called lifelong learning) allows models to learn from a sequence of tasks without forgetting what was learned before. This is important because standard neural networks suffer from "catastrophic forgetting" - when trained on new data, they tend to forget previously learned patterns.

Typical Usage:

var options = new ContinualLearningOptions
{
    Strategy = ContinualLearningStrategyType.EWC,
    Lambda = 400.0
};

How to Choose a Strategy:

  • EWC/OnlineEWC: Good baseline for regularization-based continual learning.
  • SynapticIntelligence/MAS: Online alternatives that don't need data storage.
  • LearningWithoutForgetting: Useful when previous task data isn't available.
  • GEM/A-GEM: Strong constraints that guarantee no forgetting on stored samples.
  • ExperienceReplay: Simple and effective; good when memory storage is acceptable.
  • GenerativeReplay: Privacy-preserving alternative to experience replay.
  • PackNet: Zero forgetting through parameter isolation; limited by network capacity.
  • ProgressiveNeuralNetworks: Zero forgetting with knowledge transfer; grows with tasks.
  • VCL: Principled Bayesian approach with uncertainty quantification.

Properties

BufferStrategy

Gets or sets the buffer management strategy for Experience Replay.

public ReplayBufferStrategy BufferStrategy { get; set; }

Property Value

ReplayBufferStrategy

Remarks

  • Reservoir: Random replacement, good for diverse sampling.
  • Ring: FIFO, emphasizes recent data.
  • ClassBalanced: Maintains equal representation per class.

Damping

Gets or sets the damping constant for Synaptic Intelligence.

public double Damping { get; set; }

Property Value

double

Remarks

Small constant to prevent division by zero when weights don't change much. Typical values: 0.001 to 0.1.

DropoutRate

Gets or sets the dropout rate for Monte Carlo Dropout in VCL.

public double DropoutRate { get; set; }

Property Value

double

Remarks

Controls the variation between forward passes for uncertainty estimation. Typical values: 0.1-0.5.

FisherSampleSize

Gets or sets the number of samples to use for Fisher Information estimation.

public int FisherSampleSize { get; set; }

Property Value

int

Remarks

More samples give more accurate importance estimates but take longer to compute. Used by EWC and related methods. Typical values: 100-1000.

Gamma

Gets or sets the decay factor for Online EWC.

public double Gamma { get; set; }

Property Value

double

Remarks

Controls how quickly older task importance decays in Online EWC:

  • Gamma = 1.0: Equal weight to all tasks.
  • Gamma < 1.0: More emphasis on recent tasks.

InitialLogVariance

Gets or sets the initial log-variance for weight distributions in VCL.

public double InitialLogVariance { get; set; }

Property Value

double

Remarks

Controls initial uncertainty in weight distributions. Value of -3.0 means standard deviation of approximately 0.22.

Lambda

Gets or sets the regularization strength (lambda) for weight consolidation strategies.

public double Lambda { get; set; }

Property Value

double

Remarks

For Beginners: Lambda controls the trade-off between learning new tasks and remembering old ones:

  • Higher lambda: Strong protection of old knowledge, but may struggle to learn new tasks.
  • Lower lambda: Easier to learn new tasks, but more forgetting of old tasks.

Typical values: 100-5000 for EWC/OnlineEWC, 0.1-10 for other strategies.

Margin

Gets or sets the margin for gradient constraints in GEM.

public double Margin { get; set; }

Property Value

double

Remarks

Controls how much "safety buffer" to keep for gradient constraints. Higher margin means gradients are more constrained, reducing forgetting but potentially slowing learning.

MaxBufferSize

Gets or sets the maximum buffer size for Experience Replay.

public int MaxBufferSize { get; set; }

Property Value

int

Remarks

The total number of samples that can be stored across all tasks. Typical values: 500-5000 depending on available memory.

MemorySize

Gets or sets the maximum number of samples to store per task in memory-based strategies.

public int MemorySize { get; set; }

Property Value

int

Remarks

For Beginners: This controls how many examples to remember from each task. More examples = better protection but higher memory cost.

Used by: GEM, A-GEM, ExperienceReplay.

NormalizeImportance

Gets or sets whether to normalize importance scores.

public bool NormalizeImportance { get; set; }

Property Value

bool

Remarks

Normalization can help when combining importance from different tasks or when importance values have very different scales.

NumMcSamples

Gets or sets the number of Monte Carlo samples for VCL.

public int NumMcSamples { get; set; }

Property Value

int

Remarks

More samples provide better approximation of model uncertainty but increase computation. Typical values: 5-20.

PruningRatio

Gets or sets the pruning ratio for PackNet.

public double PruningRatio { get; set; }

Property Value

double

Remarks

For Beginners: Determines how much of the remaining network capacity to use per task.

  • 0.5 means 50% of free weights are pruned after each task.
  • With ratio 0.5, you can fit approximately log2(1/ratio) tasks.

Must be between 0 and 1 (exclusive).

RandomSeed

Gets or sets the random seed for reproducibility.

public int? RandomSeed { get; set; }

Property Value

int?

Remarks

Setting a seed ensures reproducible behavior across runs. Leave as null for random behavior each time.

ReplayBatchSize

Gets or sets the batch size for generating pseudo-examples in Generative Replay.

public int ReplayBatchSize { get; set; }

Property Value

int

Remarks

Number of synthetic samples to generate per batch for rehearsal. Typical values: 16-64.

ReplayRatio

Gets or sets the ratio of replay samples to new samples in replay-based strategies.

public double ReplayRatio { get; set; }

Property Value

double

Remarks

Controls the mix of old and new data during training:

  • 0.5 means 50% replay, 50% new data.
  • Higher values emphasize remembering over learning.

Used by: ExperienceReplay, GenerativeReplay.

SampleSize

Gets or sets the batch size to sample from memory for reference gradients in A-GEM.

public int SampleSize { get; set; }

Property Value

int

Remarks

Controls how many stored samples are used to compute the reference gradient. Larger values give more accurate constraints but increase computation.

Strategy

Gets or sets the continual learning strategy to use.

public ContinualLearningStrategyType Strategy { get; set; }

Property Value

ContinualLearningStrategyType

Remarks

The strategy determines how the model balances learning new tasks with preserving old knowledge. Default is EWC (Elastic Weight Consolidation), which is a widely-used and effective baseline.

Temperature

Gets or sets the temperature for knowledge distillation in LearningWithoutForgetting.

public double Temperature { get; set; }

Property Value

double

Remarks

For Beginners: Temperature controls how "soft" the probability distribution becomes:

  • T = 1: Normal softmax (sharp, peaked distribution).
  • T = 2-5: Softer distribution that reveals class relationships.
  • T > 5: Very soft, almost uniform distribution.

Typical values for LwF: 2-4.

UseLateralConnections

Gets or sets whether to use lateral connections in Progressive Neural Networks.

public bool UseLateralConnections { get; set; }

Property Value

bool

Remarks

Lateral connections allow new task columns to receive input from previous columns, enabling knowledge transfer. Disable for simple multi-head training.