dataloader-rs 0.3.0

High-performance DataLoader for Rust with a PyTorch-like interface
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The [`Sampler`] trait.

/// Produces an ordered sequence of indices for one full pass over a dataset.
pub trait Sampler: Send + 'static {
    /// Return the index sequence for one epoch over a dataset of `dataset_len`
    /// items.
    fn indices(&mut self, dataset_len: usize) -> Vec<usize>;

    /// Number of indices [`indices`](Self::indices) returns for a dataset of
    /// `dataset_len` items, without advancing the sampler.
    ///
    /// Defaults to `dataset_len`; override it for samplers that subsample,
    /// shard, or oversample.
    fn len(&self, dataset_len: usize) -> usize {
        dataset_len
    }
}