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§
Provided Methods§
fn iter(&self) -> DatasetIterator<'_, I> ⓘwhere
Self: Sized,
fn iter(&self) -> DatasetIterator<'_, I> ⓘwhere
Self: Sized,
Returns an iterator over the dataset.
fn windows(&self, size: usize) -> WindowDataset<'_, I>where
Self: Sized,
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.