Finite Sample Streams #
This module provides the lower-level data source used by the trainer API. A SampleStream α
records a finite number of samples and computes a sample only when its index is requested. Array-
backed data is wrapped without copying, while generated data and tensor slices remain lazy.
Application code normally constructs TorchLean.Trainer.Dataset; this module is useful for manual
training loops and data-source implementations that already know their runtime scalar type.
Named halves of a stream split.
- selected : SampleStream α
Samples before the split point.
- remaining : SampleStream α
Samples at and after the split point.
Instances For
State and stream produced by deterministic shuffling.
- nextSeed : Nat
Seed to use for the next deterministic shuffle.
- stream : SampleStream α
Stream in shuffled index order.
Instances For
State and named partitions produced by a shuffled split.
- nextSeed : Nat
Seed to use for the next deterministic shuffle.
- selected : SampleStream α
Samples selected before the split point.
- remaining : SampleStream α
Samples selected at and after the split point.
Instances For
Construct a finite stream from an index function.
Instances For
Wrap an array as a finite stream without copying it.
Instances For
Materialize the samples in index order.
Instances For
Return true exactly when the stream contains no samples.
Instances For
Safely request a sample by a natural-number index.
Instances For
Transform samples when they are requested.
Instances For
Append two finite streams in index order.
Instances For
Split a stream into its first n samples and the remaining suffix.
Instances For
Shuffle the indices deterministically, returning the next seed and a stream with the new order.
Only the index permutation is stored; requesting a shuffled sample still evaluates the original stream at that index.
Instances For
Deterministically shuffle a stream and discard the next pseudo-random seed.
Instances For
Shuffle a stream once and split the result at n.
Instances For
Cycle through a nonempty stream indefinitely.
Instances For
Build a cycling sample function, rejecting an empty stream once at construction time.
Instances For
Configuration and deterministic shuffle state for epoch traversal.
- samples : SampleStream α
Samples traversed by each epoch.
- batchSize : Nat
Maximum number of samples in each batch.
- shuffle : Bool
Whether to shuffle before each epoch.
- seed : Nat
Seed threaded through deterministic shuffles.
- dropLast : Bool
Whether to discard a final batch shorter than
batchSize.
Instances For
Batches produced for one epoch together with the loader state for the next epoch.
- nextLoader : Loader
Loader state to use for the next epoch.
- batches : Array Batch
Batches produced by this epoch.
Instances For
Construct an epoch loader for a finite stream.
Instances For
Produce one epoch of batches and the loader state for the next epoch. Each shuffle applies the next seed to the original source. Keeping that source avoids retaining an additional permutation closure for every completed epoch.
Instances For
Produce one epoch and map each raw batch through collate.