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 + Sync,
S: Sampler,
C: Collate<D::Sample>,
D::Sample: Send,
impl<'dataset, D, S, C> IntoIterator for &'dataset DataLoader<D, S, C>where D: Dataset + Sync, S: Sampler, C: Collate<D::Sample>, D::Sample: Send,
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 moreimpl<D: Eq, S: Eq, C: Eq> Eq for DataLoader<D, S, C>
impl<D, S, C> StructuralEq for DataLoader<D, S, C>
impl<D, S, C> StructuralPartialEq for DataLoader<D, S, C>
Auto Trait Implementations§
impl<D, S, C> RefUnwindSafe for DataLoader<D, S, C>where C: RefUnwindSafe, D: RefUnwindSafe, S: RefUnwindSafe,
impl<D, S, C> Send for DataLoader<D, S, C>where C: Send, D: Send, S: Send,
impl<D, S, C> Sync for DataLoader<D, S, C>where C: Sync, D: Sync, S: Sync,
impl<D, S, C> Unpin for DataLoader<D, S, C>where C: Unpin, D: Unpin, S: Unpin,
impl<D, S, C> UnwindSafe for DataLoader<D, S, C>where C: UnwindSafe, D: UnwindSafe, S: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more