pub struct DataLoader { /* private fields */ }Implementations§
Source§impl DataLoader
impl DataLoader
pub fn new(dataset: Dataset, batch_size: usize, shuffle: bool) -> Self
Sourcepub fn new_distributed(
dataset: Dataset,
batch_size: usize,
shuffle: bool,
rank: usize,
world_size: usize,
) -> Self
pub fn new_distributed( dataset: Dataset, batch_size: usize, shuffle: bool, rank: usize, world_size: usize, ) -> Self
Create a distributed data loader that shards data across ranks Each rank processes 1/world_size of the data
pub fn reset(&mut self)
Sourcepub fn reset_with_seed(&mut self, seed: u64)
pub fn reset_with_seed(&mut self, seed: u64)
Reset with a specific seed (for reproducibility across epochs)
Sourcepub fn set_position(&mut self, pos: usize)
pub fn set_position(&mut self, pos: usize)
Set position (for resuming from checkpoint)
pub fn num_batches(&self) -> usize
pub fn next_batch( &mut self, device: &Device, ) -> Result<Option<(Tensor, Tensor)>>
pub fn iter<'a>(&'a mut self, device: &'a Device) -> DataLoaderIterator<'a> ⓘ
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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