Table of Contents

Class SelfPacedSampler<T>

Namespace
AiDotNet.Data.Sampling
Assembly
AiDotNet.dll

A sampler that implements self-paced learning with automatic difficulty adjustment.

public class SelfPacedSampler<T> : EpochAdaptiveSamplerBase<T>, IDataSampler

Type Parameters

T

The numeric type for losses and weights.

Inheritance
SelfPacedSampler<T>
Implements
Inherited Members

Remarks

SelfPacedSampler automatically adjusts sample selection based on the model's performance on each sample. Samples with lower loss (easier for the model) are more likely to be selected early, with harder samples gradually introduced.

For Beginners: Unlike CurriculumSampler where YOU define difficulty, SelfPacedSampler lets the MODEL decide what's easy based on its own performance:

  • Samples with low loss = easy = selected early
  • Samples with high loss = hard = selected later

This is adaptive curriculum learning - the curriculum adjusts based on the model!

Constructors

SelfPacedSampler(int, T, T, int, int?)

Initializes a new instance of the SelfPacedSampler class.

public SelfPacedSampler(int datasetSize, T initialLambda, T lambdaGrowthRate, int totalEpochs = 100, int? seed = null)

Parameters

datasetSize int

The total number of samples.

initialLambda T

Initial pace parameter (lower = stricter selection).

lambdaGrowthRate T

How much lambda increases each epoch.

totalEpochs int

Total epochs for training (used for progress tracking).

seed int?

Optional random seed for reproducibility.

Properties

Lambda

Gets the current pace parameter lambda.

public T Lambda { get; }

Property Value

T

Length

Gets the total number of samples this sampler will produce per epoch.

public override int Length { get; }

Property Value

int

Remarks

This may differ from the dataset size for oversampling or undersampling strategies.

Methods

GetIndicesCore()

Core implementation for generating indices. Override this in derived classes.

protected override IEnumerable<int> GetIndicesCore()

Returns

IEnumerable<int>

An enumerable of sample indices.

OnEpochStartCore(int)

Called when a new epoch starts. Override to implement epoch-specific behavior.

protected override void OnEpochStartCore(int epoch)

Parameters

epoch int

The current epoch number (0-based).

UpdateLoss(int, T)

Updates the loss for a specific sample.

public void UpdateLoss(int index, T loss)

Parameters

index int

The sample index.

loss T

The current loss for this sample.

UpdateLosses(IReadOnlyList<int>, IReadOnlyList<T>)

Batch updates losses for multiple samples.

public void UpdateLosses(IReadOnlyList<int> indices, IReadOnlyList<T> losses)

Parameters

indices IReadOnlyList<int>

The sample indices.

losses IReadOnlyList<T>

The losses for each sample.