Class SelfPacedSampler<T>
A sampler that implements self-paced learning with automatic difficulty adjustment.
public class SelfPacedSampler<T> : EpochAdaptiveSamplerBase<T>, IDataSampler
Type Parameters
TThe 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
datasetSizeintThe total number of samples.
initialLambdaTInitial pace parameter (lower = stricter selection).
lambdaGrowthRateTHow much lambda increases each epoch.
totalEpochsintTotal epochs for training (used for progress tracking).
seedint?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
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
epochintThe current epoch number (0-based).
UpdateLoss(int, T)
Updates the loss for a specific sample.
public void UpdateLoss(int index, T loss)
Parameters
indexintThe sample index.
lossTThe 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
indicesIReadOnlyList<int>The sample indices.
lossesIReadOnlyList<T>The losses for each sample.