RandomSampler
Models & Types ยท AiDotNet.Data.Sampling
A sampler that randomly shuffles the dataset indices each epoch.
Inheritance: DataSamplerBase โ RandomSampler
For Beginners
This sampler shuffles your data randomly before each training epoch. Shuffling is important because:
- It prevents the model from learning patterns based on data order
- It helps the model generalize better
- It ensures different batches each epoch for varied gradient updates
Example:
How It Works
RandomSampler is the default sampling strategy for most training scenarios. It shuffles the dataset indices using the Fisher-Yates algorithm for O(n) time complexity.
Constructors
| Constructor | Summary |
|---|---|
RandomSampler(int datasetSize, int? seed) |
Initializes a new instance of the RandomSampler class. |
Properties
| Property | Summary |
|---|---|
int Length { get; } |