IBatchIterable<TBatch>
Interfaces · AiDotNet.Interfaces
Defines capability to iterate through data in batches.
Known implementations: IEpisodicDataLoader<T, TInput, TOutput>, IGraphDataLoader<T>, IInputOutputDataLoader<T, TInput, TOutput>, IRLDataLoader<T>
For Beginners
Instead of feeding your model one example at a time, batching groups multiple examples together. Training in batches is faster (more efficient GPU usage) and often leads to better learning (smoother gradients).
How It Works
Data loaders that implement this interface can provide data in batches, which is the standard way to process data during model training.
Properties
| Property | Summary |
|---|---|
bool HasNext { get; } |
Gets whether there are more batches available in the current iteration. |
int BatchSize { get; set; } |
Gets or sets the number of samples per batch. |
Methods
| Method | Summary |
|---|---|
IAsyncEnumerable<TBatch> GetBatchesAsync(int? batchSize, bool shuffle, bool dropLast, int? seed, int prefetchCount, CancellationToken cancellationToken) |
Asynchronously iterates through all batches with prefetching support. |
IEnumerable<TBatch> GetBatches(int? batchSize, bool shuffle, bool dropLast, int? seed) |
Iterates through all batches in the dataset using lazy evaluation. |
TBatch GetNextBatch() |
Gets the next batch of data. |
bool TryGetNextBatch(TBatch batch) |
Attempts to get the next batch without throwing if unavailable. |