TaskBatch<T, TInput, TOutput>

Models & Types · AiDotNet.Data.Structures

Represents a batch of tasks for meta-learning with advanced batching strategies.

For Beginners

A task batch groups multiple tasks together for efficient processing. This is similar to how regular machine learning uses batches of examples, but here we’re batching entire tasks instead of individual examples.

For example, instead of processing one 5-way 1-shot task at a time, you might process 32 tasks together in a batch for faster training.

How It Works

Advanced Features Beyond Industry Standards:

This implementation includes cutting-edge features from recent meta-learning research:

  1. Task-Aware Batching: Tasks are intelligently grouped based on difficulty,

similarity, and curriculum requirements

  1. Adaptive Batch Sizes: Dynamic batch sizing based on task complexity and

memory constraints (inspired by MetaGrad, ICLR 2023)

  1. Multi-Resolution Batching: Support for hierarchical task organization

with varying K-shot configurations within the same batch

  1. Task Relationship Modeling: Explicit encoding of inter-task relationships

for improved gradient estimation (inspired by Taskonomy, CVPR 2024)

  1. Curriculum-Aware Sampling: Batches are constructed to follow optimal

learning curricula (inspired by CL-Curriculum, NeurIPS 2023)

Constructors

Constructor Summary
TaskBatch(IMetaLearningTask<T, TInput, TOutput>[] tasks, BatchingStrategy batchingStrategy, T[] taskDifficulties, T[] taskSimilarities, CurriculumStage? curriculumStage) Initializes a new instance of the TaskBatch class.

Properties

Property Summary
BatchingStrategy BatchingStrategy { get; } Gets the batching strategy used to create this batch.
CurriculumStage CurriculumStage { get; } Gets the curriculum stage this batch belongs to.
IMetaLearningTask<T, TInput, TOutput> Item { get; }
IMetaLearningTask<T, TInput, TOutput>[] Tasks { get; } Gets the array of tasks in this batch.
T AverageDifficulty { get; set; } Gets the average difficulty of tasks in this batch.
T AverageTaskSimilarity { get; set; } Gets the average task similarity within this batch.
T DifficultyVariance { get; set; } Gets the difficulty variance within this batch.
T[] TaskDifficulties { get; } Gets difficulty scores for each task (if available).
T[] TaskSimilarities { get; } Gets the similarity matrix between tasks (if available).
double EstimatedMemoryMB { get; set; } Gets the memory footprint estimate for this batch (in MB).
int BatchSize { get; } Gets the number of tasks in this batch.
int NumQueryPerClass { get; } Gets the number of query examples per class for tasks in this batch.
int NumShots { get; } Gets the number of shots per class for tasks in this batch.
int NumWays { get; } Gets the number of classes (ways) for tasks in this batch.

Methods

Method Summary
TaskBatch<T, TInput, TOutput> GetRange(int startIndex, int count) Gets a subset of tasks from this batch.
TaskBatch<T, TInput, TOutput>[] Split(int numSubBatches) Splits the batch into smaller sub-batches for distributed processing.
object GetMetadata(string key) Gets custom metadata associated with this batch.
void SetMetadata(string key, object value) Sets custom metadata for this batch.