pub struct DataLoader { /* private fields */ }Expand description
Parallel data loader that prefetches batches using worker threads.
Implementations§
Source§impl DataLoader
impl DataLoader
Sourcepub fn new(
inputs: Vec<Tensor>,
targets: Vec<Tensor>,
config: DataLoaderConfig,
) -> Result<Self, ModelError>
pub fn new( inputs: Vec<Tensor>, targets: Vec<Tensor>, config: DataLoaderConfig, ) -> Result<Self, ModelError>
Creates a new data loader from individual sample tensors and configuration.
All input tensors must have the same shape, and all target tensors must have the same shape. The number of inputs must equal the number of targets.
Sourcepub fn config(&self) -> &DataLoaderConfig
pub fn config(&self) -> &DataLoaderConfig
Returns the underlying configuration.
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Returns the total number of samples.
Sourcepub fn iter(&self) -> DataLoaderIter ⓘ
pub fn iter(&self) -> DataLoaderIter ⓘ
Creates an iterator that spawns worker threads and prefetches batches.
Each call increments the internal epoch counter, producing a different
shuffle order when config.shuffle is true.
Auto Trait Implementations§
impl !Freeze for DataLoader
impl !RefUnwindSafe for DataLoader
impl Send for DataLoader
impl !Sync for DataLoader
impl Unpin for DataLoader
impl UnsafeUnpin for DataLoader
impl UnwindSafe for DataLoader
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