IContinualLearningStrategy<T, TInput, TOutput>

Interfaces · AiDotNet.ContinualLearning.Interfaces

Strategy interface for continual learning algorithms.

Known implementations: ContinualLearningStrategyBase<T, TInput, TOutput>, IDistillationStrategy<T, TInput, TOutput>, IMemoryBasedStrategy<T, TInput, TOutput>

For Beginners

Different continual learning methods use different strategies to prevent forgetting. This interface allows the trainer to work with any strategy.

How It Works

Strategy Types:

  • Regularization-based: Add penalty terms to protect important weights (EWC, SI, MAS)
  • Replay-based: Store and replay old examples (Experience Replay, GEM)
  • Architecture-based: Use separate parameters for different tasks (Progressive Networks, PackNet)
  • Distillation-based: Use teacher model to preserve old knowledge (LwF)

Reference: De Lange et al. “A Continual Learning Survey: Defying Forgetting” (2021)

Properties

Property Summary
bool ModifiesArchitecture { get; } Gets whether this strategy modifies the model architecture.
bool RequiresMemoryBuffer { get; } Gets whether this strategy requires storing examples from previous tasks.
long MemoryUsageBytes { get; } Gets the current memory usage of the strategy in bytes.
string Name { get; } Gets the name of the strategy.

Methods

Method Summary
IReadOnlyDictionary<string, object> GetMetrics() Gets strategy-specific metrics for monitoring.
T ComputeRegularizationLoss(IFullModel<T, TInput, TOutput> model) Computes the regularization loss to prevent forgetting.
Vector<T> AdjustGradients(IFullModel<T, TInput, TOutput> model, Vector<T> gradients) Adjusts gradients to prevent forgetting.
bool IsCompatibleWith(IFullModel<T, TInput, TOutput> model) Validates that the strategy is compatible with the given model.
string GetIncompatibilityReason(IFullModel<T, TInput, TOutput> model) Gets a description of why the strategy is incompatible with a model.
void FinalizeTask(IFullModel<T, TInput, TOutput> model) Finalizes the task after training is complete.
void Load(string path) Loads the strategy state from a file.
void PrepareForTask(IFullModel<T, TInput, TOutput> model, IDataset<T, TInput, TOutput> taskData) Prepares the strategy for learning a new task.
void Reset() Resets the strategy to its initial state.
void Save(string path) Saves the strategy state to a file.