Skip to main content

Dataset

Trait Dataset 

Source
pub trait Dataset {
    // Required methods
    fn len(&self) -> i64;
    fn get_item(&self, index: i64) -> Result<Matrix>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn get_sample(&self, index: i64) -> Result<Sample> { ... }
    fn get_batch(&self, indices: &[i64]) -> Result<Batch> { ... }
    fn subset(&self, indices: Vec<i64>) -> Result<Subset<'_>>
       where Self: Sized { ... }
    fn shuffled_subset(&self, seed: u64) -> Result<Subset<'_>>
       where Self: Sized { ... }
}
Expand description

Object-safe dataset contract: indexed access and a total count.

Corresponds to the C++ pure-virtual oa::Dataset base class.

Required Methods§

Source

fn len(&self) -> i64

Total number of items in the dataset.

Source

fn get_item(&self, index: i64) -> Result<Matrix>

Retrieve one input Matrix by index.

Provided Methods§

Source

fn is_empty(&self) -> bool

Return true when the dataset contains no items.

Source

fn get_sample(&self, index: i64) -> Result<Sample>

Retrieve one sample by index.

The default implementation wraps Dataset::get_item for single-output datasets. Override to return a labeled sample.

Source

fn get_batch(&self, indices: &[i64]) -> Result<Batch>

Retrieve and collate the given sample indices in order.

§Errors

Returns sample or collation errors.

Source

fn subset(&self, indices: Vec<i64>) -> Result<Subset<'_>>
where Self: Sized,

Return a zero-copy indexed view over this dataset.

Corresponds to oa::DsSubset.

§Errors

Returns an error for a negative parent length or an out-of-range index.

Source

fn shuffled_subset(&self, seed: u64) -> Result<Subset<'_>>
where Self: Sized,

Return a zero-copy view over every item in deterministic shuffle order. A nonzero seed reproduces the same permutation on each call.

§Errors

Returns the index-building, shuffle, and subset errors of the pieces it composes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§