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>
impl<D> DataLoader<D, SequentialSampler, DefaultCollate>
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 duplicate 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>
impl<'dataset, D, S, C> IntoIterator for &'dataset DataLoader<D, S, C>
Source§impl<D, S, C> Len for DataLoader<D, S, C>
impl<D, S, C> Len for DataLoader<D, S, C>
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: PartialOrd, S: PartialOrd, C: PartialOrd> PartialOrd for DataLoader<D, S, C>
impl<D: PartialOrd, S: PartialOrd, C: PartialOrd> PartialOrd for DataLoader<D, S, C>
impl<D: Eq, S: Eq, C: Eq> Eq for DataLoader<D, S, C>
impl<D, S, C> StructuralPartialEq for DataLoader<D, S, C>
Auto Trait Implementations§
impl<D, S, C> Freeze for DataLoader<D, S, C>
impl<D, S, C> RefUnwindSafe for DataLoader<D, S, C>
impl<D, S, C> Send for DataLoader<D, S, C>
impl<D, S, C> Sync for DataLoader<D, S, C>
impl<D, S, C> Unpin for DataLoader<D, S, C>
impl<D, S, C> UnwindSafe for DataLoader<D, S, C>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more