Stream Training #
Regression stream and paired-stream training for generated or resampled workloads.
Train a regression trainer from a step-indexed Float sample stream.
Use this when the "dataset" is really a recipe:
- diffusion draws a fresh noised image at each step,
- PDE examples resample collocation points,
- operator-learning demos cycle generated batches while evaluating on one fixed probe.
The public contract is still trainer-shaped. The caller supplies sampleAt step, TorchLean owns
the optimizer and runner state, and the returned value is the same trained model handle used by
ordinary static-dataset training, plus a curve of evaluation loss on evalSample.
Instances For
Train a regression trainer from a Float sample stream using the trainer's attached runtime settings.
Stream analogue of trainer.train: most static datasets should use the unified method, while
generated or resampled workloads should use this entrypoint so they do not hand-roll module loops.
Instances For
Train two regression trainers with an alternating Float sample stream.
Public paired-model training path. A GAN is the motivating case: the generator receives one supervised warm-up sample per step, while the discriminator may receive both real and fake score samples. The trainer API handles the alternating optimizer mechanics and lets the example provide only the domain-specific pieces:
firstSampleAt stepfor the first model,secondSamplesAt stepfor one or more second-model updates,evalTotal predictFirst predictSecondfor the scalar curve to record.
The callback sees only prediction functions, never modules or optimizer states. That boundary lets examples define meaningful metrics without becoming miniature copies of the runtime trainer.
The trained handles use the paired evalTotal value for their before/after summaries. For coupled
models, the generator and discriminator are judged by one task-level scalar, not by two unrelated
dataset losses. If a future caller needs separate reports, it should expose them through the
curve/history artifact rather than reopening the modules.