pub struct BatchSampler<S: Sampler> { /* private fields */ }Expand description
Batches indices produced by an inner Sampler.
Implementations§
Source§impl<S: Sampler> BatchSampler<S>
impl<S: Sampler> BatchSampler<S>
Sourcepub fn new(sampler: S, batch_size: usize, drop_last: bool) -> Self
pub fn new(sampler: S, batch_size: usize, drop_last: bool) -> Self
Build a batch sampler from an index sampler.
pub fn batch_size(&self) -> usize
pub fn drop_last(&self) -> bool
pub fn set_batch_size(&mut self, batch_size: usize)
pub fn set_drop_last(&mut self, drop_last: bool)
Sourcepub fn len(&self, dataset_len: usize) -> usize
pub fn len(&self, dataset_len: usize) -> usize
Number of batches in one epoch, without advancing the sampler.
Sourcepub fn num_batches(&self, n_indices: usize) -> usize
pub fn num_batches(&self, n_indices: usize) -> usize
Number of batches n_indices sampled indices are grouped into.
Auto Trait Implementations§
impl<S> Forget for BatchSampler<S>
impl<S> Freeze for BatchSampler<S>where
S: Freeze,
impl<S> RefUnwindSafe for BatchSampler<S>where
S: RefUnwindSafe,
impl<S> Send for BatchSampler<S>
impl<S> Sync for BatchSampler<S>where
S: Sync,
impl<S> Unpin for BatchSampler<S>where
S: Unpin,
impl<S> UnsafeUnpin for BatchSampler<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for BatchSampler<S>where
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
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