Skip to content

tenzr::data::RandomSampler

Sampler that yields a shuffled permutation of the dataset indices.

#include <sampler.h>

Inherits from tenzr::data::Sampler

Public Functions

Name
RandomSampler(size_t dataset_size, std::optional< uint64_t > seed =std::nullopt)
virtual std::vector< size_t > Indices() const override
virtual size_t Size() const override

Additional inherited members

Public Functions inherited from tenzr::data::Sampler

Name
virtual ~Sampler() =default

Public Functions Documentation

function RandomSampler

explicit RandomSampler(
    size_t dataset_size,
    std::optional< uint64_t > seed =std::nullopt
)

Parameters:

  • dataset_size Number of samples to shuffle.
  • seed Optional RNG seed; falls back to the default generator.

Create a sampler that shuffles dataset_size indices with an optional fixed seed.

function Indices

virtual std::vector< size_t > Indices() const override

Return:

  • Shuffled indices.
  • Randomly ordered index list.

Reimplements: tenzr::data::Sampler::Indices

Return a shuffled permutation of 0..size-1.

function Size

inline virtual size_t Size() const override

Return: Number of indices.

Reimplements: tenzr::data::Sampler::Size