pub trait DataLoader<B: Backend, O>: Send + Sync {
// Required methods
fn iter<'a>(&'a self) -> Box<dyn DataLoaderIterator<O> + 'a>;
fn num_items(&self) -> usize;
fn to_device(&self, device: &B::Device) -> Arc<dyn DataLoader<B, O>>;
fn slice(&self, start: usize, end: usize) -> Arc<dyn DataLoader<B, O>>;
}Available on crate features
std and dataset only.Expand description
A data loader that can be used to iterate over a dataset.
Required Methods§
Sourcefn 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.
Sourcefn 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.
Sourcefn to_device(&self, device: &B::Device) -> Arc<dyn DataLoader<B, O>>
fn to_device(&self, device: &B::Device) -> Arc<dyn DataLoader<B, O>>
Move the data loader to the given device, ensuring the batches are assigned to the correct device.
Sourcefn slice(&self, start: usize, end: usize) -> Arc<dyn DataLoader<B, O>>
fn slice(&self, start: usize, end: usize) -> Arc<dyn DataLoader<B, O>>
Returns a new data loader containing a subset of the data.
The subset includes items from start (inclusive) to end (exclusive),
preserving the batch size and ordering of the original data loader.
§Arguments
start- The starting index of the subset (inclusive).end- The ending index of the subset (exclusive).
§Returns
A boxed DataLoader instance containing only the specified range.