TorchLean Stream Trainer Implementation #
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.
This is the 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.
This is the 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 facade owns 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 is the important boundary: examples can define meaningful metrics, but they do not become 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.