Builds batches with a fixed, grouped number of examples per class – see the file-level note for why this exists and what it deliberately doesn't own.
More...
#include <StreamAlignedBatcher.h>
|
| | StreamAlignedBatcher (const float *X, const float *Y, const int *labels, size_t numSamples, size_t xStride, size_t yStride, int numClasses, int perClass, unsigned seed=42) |
| size_t | NumBatchesPerEpoch () const noexcept |
| | Number of complete batches obtainable per epoch, limited by the rarest class's sample count (matches the Python version's behavior – some samples from more common classes go unused each epoch, rather than padding/repeating to force even usage).
|
| void | GetBatch (float *X_out, float *Y_out, int *labels_out) noexcept |
| | Fills the next batch into caller-provided, pre-allocated output buffers. Rows are GROUPED by class: rows [0, perClass) are class 0, [perClass, 2*perClass) are class 1, etc. – same convention as the Python version, so per-class slicing for cache-averaging is a trivial contiguous range.
|
| int | GetBatchSize () const noexcept |
| | Rows per batch: numClasses * perClass.
|
| int | GetPerClass () const noexcept |
| | Examples per class in each batch, as given at construction.
|
| int | GetNumClasses () const noexcept |
| | Number of distinct classes, as given at construction.
|
| size_t | GetXStride () const noexcept |
| | Floats per X row, as given at construction.
|
| size_t | GetYStride () const noexcept |
| | Floats per Y row, as given at construction.
|
Builds batches with a fixed, grouped number of examples per class – see the file-level note for why this exists and what it deliberately doesn't own.
◆ StreamAlignedBatcher()
| Deep::StreamAlignedBatcher::StreamAlignedBatcher |
( |
const float * | X, |
|
|
const float * | Y, |
|
|
const int * | labels, |
|
|
size_t | numSamples, |
|
|
size_t | xStride, |
|
|
size_t | yStride, |
|
|
int | numClasses, |
|
|
int | perClass, |
|
|
unsigned | seed = 42 ) |
- Parameters
-
| X | Flat, row-major input data, numSamples rows of xStride floats each. NOT owned. |
| Y | Flat, row-major target data, numSamples rows of yStride floats each. NOT owned. |
| labels | Integer class label per sample, length numSamples. NOT owned. |
| numSamples | Total number of samples in X/Y/labels. |
| xStride | Floats per X row. |
| yStride | Floats per Y row. |
| numClasses | Number of distinct classes (labels expected in [0, numClasses)). |
| perClass | Examples per class per batch (batch size = numClasses * perClass). |
| seed | RNG seed for per-class shuffling; defaults to a fixed value for reproducible batch order run-to-run. |
◆ GetBatch()
| void Deep::StreamAlignedBatcher::GetBatch |
( |
float * | X_out, |
|
|
float * | Y_out, |
|
|
int * | labels_out ) |
|
noexcept |
Fills the next batch into caller-provided, pre-allocated output buffers. Rows are GROUPED by class: rows [0, perClass) are class 0, [perClass, 2*perClass) are class 1, etc. – same convention as the Python version, so per-class slicing for cache-averaging is a trivial contiguous range.
- Parameters
-
| X_out | Must be sized (numClasses*perClass) * xStride. |
| Y_out | Must be sized (numClasses*perClass) * yStride. |
| labels_out | Must be sized (numClasses*perClass). |
◆ GetBatchSize()
| int Deep::StreamAlignedBatcher::GetBatchSize |
( |
| ) |
const |
|
inlinenoexcept |
Rows per batch: numClasses * perClass.
◆ GetNumClasses()
| int Deep::StreamAlignedBatcher::GetNumClasses |
( |
| ) |
const |
|
inlinenoexcept |
Number of distinct classes, as given at construction.
◆ GetPerClass()
| int Deep::StreamAlignedBatcher::GetPerClass |
( |
| ) |
const |
|
inlinenoexcept |
Examples per class in each batch, as given at construction.
◆ GetXStride()
| size_t Deep::StreamAlignedBatcher::GetXStride |
( |
| ) |
const |
|
inlinenoexcept |
Floats per X row, as given at construction.
◆ GetYStride()
| size_t Deep::StreamAlignedBatcher::GetYStride |
( |
| ) |
const |
|
inlinenoexcept |
Floats per Y row, as given at construction.
◆ NumBatchesPerEpoch()
| size_t Deep::StreamAlignedBatcher::NumBatchesPerEpoch |
( |
| ) |
const |
|
noexcept |
Number of complete batches obtainable per epoch, limited by the rarest class's sample count (matches the Python version's behavior – some samples from more common classes go unused each epoch, rather than padding/repeating to force even usage).
The documentation for this class was generated from the following files: