Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
Loading...
Searching...
No Matches
Deep::StreamAlignedBatcher Class Reference

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>

Public Member Functions

 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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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
XFlat, row-major input data, numSamples rows of xStride floats each. NOT owned.
YFlat, row-major target data, numSamples rows of yStride floats each. NOT owned.
labelsInteger class label per sample, length numSamples. NOT owned.
numSamplesTotal number of samples in X/Y/labels.
xStrideFloats per X row.
yStrideFloats per Y row.
numClassesNumber of distinct classes (labels expected in [0, numClasses)).
perClassExamples per class per batch (batch size = numClasses * perClass).
seedRNG seed for per-class shuffling; defaults to a fixed value for reproducible batch order run-to-run.

Member Function Documentation

◆ 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_outMust be sized (numClasses*perClass) * xStride.
Y_outMust be sized (numClasses*perClass) * yStride.
labels_outMust 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: