Skip to main content

Dataset

Trait Dataset 

Source
pub trait Dataset: Send + Sync {
    // Required methods
    fn len(&self) -> usize;
    fn get(&self, index: usize) -> Sample;
    fn feature_shape(&self) -> &[usize];
    fn target_shape(&self) -> &[usize];

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn name(&self) -> &str { ... }
}
Expand description

A dataset is an indexed collection of samples.

Implementations must be Send + Sync so DataLoader can read from multiple threads when parallel prefetching is enabled.

Required Methods§

Source

fn len(&self) -> usize

Total number of samples in the dataset.

Source

fn get(&self, index: usize) -> Sample

Retrieve the sample at position index.

§Panics

May panic if index >= self.len().

Source

fn feature_shape(&self) -> &[usize]

The shape of a single feature sample (without batch dim).

Source

fn target_shape(&self) -> &[usize]

The shape of a single target sample (without batch dim).

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether the dataset is empty.

Source

fn name(&self) -> &str

Optional human-readable name.

Implementors§