pub struct BatchDataLoader<B: Backend, I, O> { /* private fields */ }Available on crate features
dataset and std only.Expand description
A data loader that can be used to iterate over a dataset in batches.
Implementations§
Source§impl<B: Backend, I, O> BatchDataLoader<B, I, O>
impl<B: Backend, I, O> BatchDataLoader<B, I, O>
Sourcepub fn new(
strategy: Box<dyn BatchStrategy<I>>,
dataset: Arc<dyn Dataset<I>>,
batcher: Arc<dyn Batcher<B, I, O>>,
device: B::Device,
rng: Option<StdRng>,
) -> Self
pub fn new( strategy: Box<dyn BatchStrategy<I>>, dataset: Arc<dyn Dataset<I>>, batcher: Arc<dyn Batcher<B, I, O>>, device: B::Device, rng: Option<StdRng>, ) -> Self
Sourcepub fn batch_reading(self, enabled: bool) -> Self
pub fn batch_reading(self, enabled: bool) -> Self
Enables Dataset::get_many reads using the strategy’s batch size (default: false).
Unknown or zero batch sizes read one item at a time. Items are still passed to the strategy individually; unread items remain buffered after an early batch. Missing items or a mismatched result length panic without rereading.
Trait Implementations§
Source§impl<B: Backend, I, O> Clone for BatchDataLoader<B, I, O>
impl<B: Backend, I, O> Clone for BatchDataLoader<B, I, O>
Source§impl<B, I, O> DataLoader<B, O> for BatchDataLoader<B, I, O>
impl<B, I, O> DataLoader<B, O> for BatchDataLoader<B, I, O>
Source§fn iter<'a>(&'a self) -> Box<dyn DataLoaderIterator<O> + 'a>
fn iter<'a>(&'a self) -> Box<dyn DataLoaderIterator<O> + 'a>
Returns a boxed iterator to iterate over the data loader.
Source§fn num_items(&self) -> usize
fn num_items(&self) -> usize
The number of items (not the number of batches nor the number of iterations),
corresponding to the items_total of the progress returned by the iterator.
Auto Trait Implementations§
impl<B, I, O> !RefUnwindSafe for BatchDataLoader<B, I, O>
impl<B, I, O> !UnwindSafe for BatchDataLoader<B, I, O>
impl<B, I, O> Freeze for BatchDataLoader<B, I, O>
impl<B, I, O> Send for BatchDataLoader<B, I, O>
impl<B, I, O> Sync for BatchDataLoader<B, I, O>
impl<B, I, O> Unpin for BatchDataLoader<B, I, O>
impl<B, I, O> UnsafeUnpin for BatchDataLoader<B, I, O>where
Box<dyn BatchStrategy<I>>: UnsafeUnpin,
Arc<dyn Dataset<I>>: UnsafeUnpin,
Arc<dyn Batcher<B, I, O>>: UnsafeUnpin,
<B as BackendTypes>::Device: UnsafeUnpin,
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