pulsatrix
Loading...
Searching...
No Matches
pulsatrix::ShuffleSampler Class Reference

Visits indices [0, dataset_size) in a seeded pseudo-random permutation – reproducible across runs given the same seed (std::mt19937), re-shuffled fresh each reset() call (a new epoch is a new permutation, not the same one repeated). More...

#include <sampler.hpp>

Inheritance diagram for pulsatrix::ShuffleSampler:
Collaboration diagram for pulsatrix::ShuffleSampler:

Public Member Functions

 ShuffleSampler (unsigned seed)
 
void reset (int64_t dataset_size) override
 Begins a new epoch over a dataset of the given size.
 
std::optional< int64_t > next () override
 Fetches the next index in this epoch's order.
 
- Public Member Functions inherited from pulsatrix::Sampler
virtual ~Sampler ()=default
 

Detailed Description

Visits indices [0, dataset_size) in a seeded pseudo-random permutation – reproducible across runs given the same seed (std::mt19937), re-shuffled fresh each reset() call (a new epoch is a new permutation, not the same one repeated).

Constructor & Destructor Documentation

◆ ShuffleSampler()

pulsatrix::ShuffleSampler::ShuffleSampler ( unsigned  seed)
explicit

Member Function Documentation

◆ next()

std::optional< int64_t > pulsatrix::ShuffleSampler::next ( )
overridevirtual

Fetches the next index in this epoch's order.

Returns
The next index, or std::nullopt once every index has been produced.

Implements pulsatrix::Sampler.

◆ reset()

void pulsatrix::ShuffleSampler::reset ( int64_t  dataset_size)
overridevirtual

Begins a new epoch over a dataset of the given size.

Parameters
dataset_sizeNumber of samples to produce indices for. Must be >= 0 – internal invariant (PULSATRIX_ASSERT, not throw): DataLoader always calls this with Dataset::size()'s return value directly, never unvalidated external input.

Implements pulsatrix::Sampler.


The documentation for this class was generated from the following file: