Struct ai_dataloader::indexable::DataLoader
source · pub struct DataLoader<D, S = SequentialSampler, C = DefaultCollate> { /* private fields */ }Expand description
Data loader. Combines a dataset and a sampler, and provides an iterable over the given dataset.
use ai_dataloader::indexable::DataLoader;
let loader = DataLoader::builder(vec![(0, "hola"), (1, "hello"), (2, "hallo"), (3, "bonjour")]).batch_size(2).shuffle().build();
for (label, text) in &loader {
println!("Label {label:?}");
println!("Text {text:?}");
}Implementations§
source§impl<D> DataLoader<D, SequentialSampler, DefaultCollate>where
D: Dataset,
DefaultCollate: Collate<D::Sample>,
impl<D> DataLoader<D, SequentialSampler, DefaultCollate>where D: Dataset, DefaultCollate: Collate<D::Sample>,
sourcepub fn builder(dataset: D) -> Builder<D, SequentialSampler, DefaultCollate>
pub fn builder(dataset: D) -> Builder<D, SequentialSampler, DefaultCollate>
Helper to return a DataLoader builder.
Trait Implementations§
source§impl<D: Clone, S: Clone, C: Clone> Clone for DataLoader<D, S, C>
impl<D: Clone, S: Clone, C: Clone> Clone for DataLoader<D, S, C>
source§fn clone(&self) -> DataLoader<D, S, C>
fn clone(&self) -> DataLoader<D, S, C>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<'dataset, D, S, C> IntoIterator for &'dataset DataLoader<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<'dataset, D, S, C> IntoIterator for &'dataset DataLoader<D, S, C>where D: Dataset, S: Sampler, C: Collate<D::Sample>,
source§impl<D, S, C> Len for DataLoader<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D, S, C> Len for DataLoader<D, S, C>where D: Dataset, S: Sampler, C: Collate<D::Sample>,
source§impl<D: Ord, S: Ord, C: Ord> Ord for DataLoader<D, S, C>
impl<D: Ord, S: Ord, C: Ord> Ord for DataLoader<D, S, C>
source§fn cmp(&self, other: &DataLoader<D, S, C>) -> Ordering
fn cmp(&self, other: &DataLoader<D, S, C>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<D: PartialEq, S: PartialEq, C: PartialEq> PartialEq<DataLoader<D, S, C>> for DataLoader<D, S, C>
impl<D: PartialEq, S: PartialEq, C: PartialEq> PartialEq<DataLoader<D, S, C>> for DataLoader<D, S, C>
source§fn eq(&self, other: &DataLoader<D, S, C>) -> bool
fn eq(&self, other: &DataLoader<D, S, C>) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl<D: PartialOrd, S: PartialOrd, C: PartialOrd> PartialOrd<DataLoader<D, S, C>> for DataLoader<D, S, C>
impl<D: PartialOrd, S: PartialOrd, C: PartialOrd> PartialOrd<DataLoader<D, S, C>> for DataLoader<D, S, C>
source§fn partial_cmp(&self, other: &DataLoader<D, S, C>) -> Option<Ordering>
fn partial_cmp(&self, other: &DataLoader<D, S, C>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read more