pub struct DataLoader<'ds> { /* private fields */ }Expand description
Stateful batch iterator over a borrowed Dataset.
Corresponds to oa::DataLoader.
Implementations§
Source§impl<'ds> DataLoader<'ds>
impl<'ds> DataLoader<'ds>
Sourcepub fn new(dataset: &'ds dyn Dataset, config: DataLoaderConfig) -> Result<Self>
pub fn new(dataset: &'ds dyn Dataset, config: DataLoaderConfig) -> Result<Self>
Construct a data loader and build the initial index order.
§Errors
Returns an error for a non-positive batch size, a negative dataset length, index allocation failure, or an unavailable clock for seed zero.
Sourcepub fn next_batch(&mut self) -> Result<Option<Batch>>
pub fn next_batch(&mut self) -> Result<Option<Batch>>
Advance to the next batch; None means the epoch is exhausted.
§Errors
Sample and collation failures are propagated without dropping samples or advancing the batch cursor. A caller may retry or explicitly reset.
Sourcepub fn reset_epoch(&mut self, epoch: u64) -> Result<()>
pub fn reset_epoch(&mut self, epoch: u64) -> Result<()>
Reset for a new data pass, deriving the shuffle order from the
configured seed mixed with the epoch number so each epoch iterates a
different deterministic order — the equivalent of reshuffling a
dataset between epochs. reset_epoch(0) reproduces Self::reset.
§Errors
Returns the index-building errors described by Self::new. A failed
reset leaves the existing order and cursor unchanged.
Sourcepub fn num_batches(&self) -> i64
pub fn num_batches(&self) -> i64
Number of batches in the current epoch.
Sourcepub fn current_batch(&self) -> i64
pub fn current_batch(&self) -> i64
Index of the next batch that will be returned.