tenzr::data::BatchSampler¶
Groups indices produced by a Sampler into fixed-size batches.
#include <sampler.h>
Public Functions¶
| Name | |
|---|---|
| BatchSampler(std::shared_ptr< Sampler > sampler, size_t batch_size, bool drop_last =false) | |
| std::vector< std::vector< size_t > > | Batches() const |
| size_t | NumBatches() const |
| size_t | BatchSize() const |
| bool | DropLast() const |
Public Functions Documentation¶
function BatchSampler¶
Parameters:
- sampler Underlying index sampler; must not be null.
- batch_size Batch size, which must be positive.
- drop_last When true, discard a trailing partial batch.
Group another sampler's indices into fixed-size batches.
function Batches¶
Return:
- Batched indices, each inner vector one batch.
- One index vector per batch.
Materialize the sampler's indices as a list of batches.
function NumBatches¶
Return:
- Number of batches produced.
- Batch count, dropping the remainder when drop_last is set.
Number of batches the underlying sampler will produce.
function BatchSize¶
Return: Configured batch size.
function DropLast¶
Return: true when the final partial batch is dropped.