ITaskSampler<T, TInput, TOutput>
Interfaces ยท AiDotNet.Interfaces
Controls the strategy for sampling meta-learning tasks (episodes) from a dataset. Implementations can provide uniform, balanced, curriculum-based, or dynamic sampling.
Known implementations: BalancedTaskSampler<T, TInput, TOutput>, CurriculumTaskSampler<T, TInput, TOutput>, DynamicTaskSampler<T, TInput, TOutput>, EpisodicDataLoaderTaskSamplerAdapter<T, TInput, TOutput>, ModelPredictiveTaskSampler<T, TInput, TOutput>, UniformTaskSampler<T, TInput, TOutput>
For Beginners
A task sampler decides which tasks (episodes) to give the meta-learner during training. Different strategies can make training faster or more robust:
- Uniform: Picks tasks completely at random โ simple and effective.
- Balanced: Ensures every class appears equally often across tasks.
- Dynamic: Focuses on tasks the model struggles with the most.
- Curriculum: Starts with easy tasks, gradually increases difficulty.
Properties
| Property | Summary |
|---|---|
int NumQueryPerClass { get; } |
Gets the number of query examples per class used by this sampler. |
int NumShots { get; } |
Gets the K-shot configuration used by this sampler. |
int NumWays { get; } |
Gets the N-way configuration used by this sampler. |
Methods
| Method | Summary |
|---|---|
IEpisode<T, TInput, TOutput> SampleOne() |
Samples a single episode from the underlying meta-dataset. |
TaskBatch<T, TInput, TOutput> SampleBatch(int batchSize) |
Samples a batch of tasks from the underlying meta-dataset. |
void SetSeed(int seed) |
Sets the random seed for reproducible sampling. |
void UpdateWithFeedback(IReadOnlyList<IEpisode<T, TInput, TOutput>> episodes, IReadOnlyList<double> losses) |
Updates the sampler state after observing a loss for a batch of tasks. |