Trait burn::data::dataloader::Dataset

pub trait Dataset<I>: Send + Sync {
    // Required methods
    fn get(&self, index: usize) -> Option<I>;
    fn len(&self) -> usize;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn iter(&self) -> DatasetIterator<'_, I> 
       where Self: Sized { ... }
    fn windows(&self, size: usize) -> WindowDataset<'_, I>
       where Self: Sized { ... }
}
Expand description

The dataset trait defines a basic collection of items with a predefined size.

Required Methods§

fn get(&self, index: usize) -> Option<I>

Gets the item at the given index.

fn len(&self) -> usize

Gets the number of items in the dataset.

Provided Methods§

fn is_empty(&self) -> bool

Checks if the dataset is empty.

fn iter(&self) -> DatasetIterator<'_, I>
where Self: Sized,

Returns an iterator over the dataset.

fn windows(&self, size: usize) -> WindowDataset<'_, I>
where Self: Sized,

Returns a new Dataset of all the windows of length size. The windows overlap. Is empty if the input Dataset is shorter than size.

§Panics

Panics if size is 0.

§Examples
use crate::burn_dataset::{Dataset,InMemDataset};
let items = [1, 2, 3, 4].to_vec();
let dataset = InMemDataset::new(items.clone());

let windows = dataset.windows(2);

assert_eq!(windows.len(), 3);
§Returns

A WindowDataset instance.

Trait Implementations§

§

impl<I> Dataset<I> for Box<dyn Dataset<I>>

§

fn get(&self, index: usize) -> Option<I>

Gets the item at the given index.
§

fn len(&self) -> usize

Gets the number of items in the dataset.
§

fn is_empty(&self) -> bool

Checks if the dataset is empty.
§

fn iter(&self) -> DatasetIterator<'_, I>
where Self: Sized,

Returns an iterator over the dataset.
§

fn windows(&self, size: usize) -> WindowDataset<'_, I>
where Self: Sized,

Returns a new Dataset of all the windows of length size. The windows overlap. Is empty if the input Dataset is shorter than size. Read more

Implementations on Foreign Types§

§

impl<D, I> Dataset<I> for Box<D>
where D: Dataset<I>,

§

fn get(&self, index: usize) -> Option<I>

§

fn len(&self) -> usize

§

impl<D, I> Dataset<I> for Arc<D>
where D: Dataset<I>,

§

fn get(&self, index: usize) -> Option<I>

§

fn len(&self) -> usize

§

impl<I> Dataset<I> for Box<dyn Dataset<I>>

§

fn get(&self, index: usize) -> Option<I>

§

fn len(&self) -> usize

§

impl<I> Dataset<I> for Arc<dyn Dataset<I>>

§

fn get(&self, index: usize) -> Option<I>

§

fn len(&self) -> usize

Implementors§

§

impl Dataset<ImageDatasetItem> for ImageFolderDataset

§

impl Dataset<MnistItem> for MnistDataset

§

impl<'a, I> Dataset<Vec<I>> for WindowDataset<'a, I>

§

impl<D, I> Dataset<I> for ComposedDataset<D>
where D: Dataset<I>, I: Clone,

§

impl<D, I> Dataset<I> for PartialDataset<D, I>
where D: Dataset<I>, I: Clone + Send + Sync,

§

impl<D, I> Dataset<I> for SamplerDataset<D, I>
where D: Dataset<I>, I: Send + Sync,

§

impl<D, I> Dataset<I> for ShuffledDataset<D, I>
where D: Dataset<I>, I: Clone + Send + Sync,

§

impl<D, M, I, O> Dataset<O> for MapperDataset<D, M, I>
where D: Dataset<I>, M: Mapper<I, O> + Send + Sync, I: Send + Sync, O: Send + Sync,

§

impl<I> Dataset<I> for InMemDataset<I>
where I: Clone + Send + Sync,

§

impl<I> Dataset<I> for SqliteDataset<I>