pub struct TensorDataLoader { /* private fields */ }Expand description
Batch data loader with deterministic shuffling and epoch tracking.
Samples are stored as (feature_vector, label) pairs. Each epoch iterates
through all samples in (optionally shuffled) order, yielding fixed-size
batches.
Implementations§
Source§impl TensorDataLoader
impl TensorDataLoader
Sourcepub fn new(config: DataLoaderConfig, seed: u64) -> Self
pub fn new(config: DataLoaderConfig, seed: u64) -> Self
Create a new data loader with the given config and PRNG seed.
Sourcepub fn add_sample(&mut self, data: Vec<f64>, label: &str)
pub fn add_sample(&mut self, data: Vec<f64>, label: &str)
Add a single training sample.
Sourcepub fn next_batch(&mut self) -> Option<DataBatch>
pub fn next_batch(&mut self) -> Option<DataBatch>
Return the next batch, or None if there are no samples.
When the current epoch is exhausted the loader automatically increments the epoch counter, reshuffles (if enabled), and begins yielding batches from the new epoch.
Sourcepub fn shuffle_indices(&mut self)
pub fn shuffle_indices(&mut self)
Perform a Fisher-Yates shuffle on self.indices using an FNV-1a-based
PRNG seeded from seed + current_epoch.
Sourcepub fn total_samples(&self) -> usize
pub fn total_samples(&self) -> usize
Total number of loaded samples.
Sourcepub fn total_batches(&self) -> usize
pub fn total_batches(&self) -> usize
Total number of batches per epoch.
Returns ceil(samples / batch_size) normally, or
floor(samples / batch_size) when drop_last is enabled.
Sourcepub fn current_epoch(&self) -> usize
pub fn current_epoch(&self) -> usize
Current epoch (zero-based).
Sourcepub fn progress(&self) -> f64
pub fn progress(&self) -> f64
Fraction of the current epoch that has been consumed (0.0..=1.0).
Sourcepub fn stats(&self) -> DataLoaderStats
pub fn stats(&self) -> DataLoaderStats
Snapshot of the loader’s current statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TensorDataLoader
impl RefUnwindSafe for TensorDataLoader
impl Send for TensorDataLoader
impl Sync for TensorDataLoader
impl Unpin for TensorDataLoader
impl UnsafeUnpin for TensorDataLoader
impl UnwindSafe for TensorDataLoader
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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