Struct ai_dataloader::Builder
source · [−]pub struct Builder<D, S = SequentialSampler, C = DefaultCollate>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,{ /* private fields */ }Expand description
Basic builder for creating dataloader.
Implementations
sourceimpl<D> Builder<D, SequentialSampler, DefaultCollate>where
D: Dataset,
DefaultCollate: Collate<D::Sample>,
impl<D> Builder<D, SequentialSampler, DefaultCollate>where
D: Dataset,
DefaultCollate: Collate<D::Sample>,
sourceimpl<D, S, C> Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D, S, C> Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
sourcepub fn shuffle(self) -> Builder<D, RandomSampler, C>
pub fn shuffle(self) -> Builder<D, RandomSampler, C>
Use a random sampler.
sourcepub fn batch_size(self, batch_size: usize) -> Self
pub fn batch_size(self, batch_size: usize) -> Self
Set the number of elements in a batch.
sourcepub fn drop_last(self) -> Self
pub fn drop_last(self) -> Self
Drop the lasts element if they don’t feat into a batch. For instance if a dataset have 13
samples and a batch_size of 5, the last 3 samples will be droped.
sourcepub fn collate_fn<CF>(self, collate_fn: CF) -> Builder<D, S, CF>where
CF: Collate<D::Sample>,
pub fn collate_fn<CF>(self, collate_fn: CF) -> Builder<D, S, CF>where
CF: Collate<D::Sample>,
Set a custom collate function.
sourcepub fn build(self) -> DataLoader<D, S, C>
pub fn build(self) -> DataLoader<D, S, C>
Create a Dataloader from a Builder.
Trait Implementations
sourceimpl<D: Clone, S: Clone, C: Clone> Clone for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D: Clone, S: Clone, C: Clone> Clone for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
sourceimpl<D: Debug, S: Debug, C: Debug> Debug for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D: Debug, S: Debug, C: Debug> Debug for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
sourceimpl<D: Hash, S: Hash, C: Hash> Hash for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D: Hash, S: Hash, C: Hash> Hash for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
sourceimpl<D: Ord, S: Ord, C: Ord> Ord for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D: Ord, S: Ord, C: Ord> Ord for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<D: PartialEq, S: PartialEq, C: PartialEq> PartialEq<Builder<D, S, C>> for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D: PartialEq, S: PartialEq, C: PartialEq> PartialEq<Builder<D, S, C>> for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
sourceimpl<D: PartialOrd, S: PartialOrd, C: PartialOrd> PartialOrd<Builder<D, S, C>> for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D: PartialOrd, S: PartialOrd, C: PartialOrd> PartialOrd<Builder<D, S, C>> for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
sourcefn partial_cmp(&self, other: &Builder<D, S, C>) -> Option<Ordering>
fn partial_cmp(&self, other: &Builder<D, S, C>) -> Option<Ordering>
1.0.0 · sourcefn 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 Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D, S, C> StructuralEq for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
impl<D, S, C> StructuralPartialEq for Builder<D, S, C>where
D: Dataset,
S: Sampler,
C: Collate<D::Sample>,
Auto Trait Implementations
impl<D, S, C> RefUnwindSafe for Builder<D, S, C>where
C: RefUnwindSafe,
D: RefUnwindSafe,
S: RefUnwindSafe,
impl<D, S, C> Send for Builder<D, S, C>where
C: Send,
D: Send,
S: Send,
impl<D, S, C> Sync for Builder<D, S, C>where
C: Sync,
D: Sync,
S: Sync,
impl<D, S, C> Unpin for Builder<D, S, C>where
C: Unpin,
D: Unpin,
S: Unpin,
impl<D, S, C> UnwindSafe for Builder<D, S, C>where
C: UnwindSafe,
D: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more