TorchLean API

NN.API.Trainer.FixedSample

Fixed-Sample Training #

Some runnable examples train repeatedly on one caller-supplied sample:

  1. build a model with TorchLean.nn.withModel,
  2. wrap it as a ScalarModuleDef (model + supervised loss),
  3. load or synthesize one supervised sample (x, y),
  4. run steps optimizer updates on that fixed sample, and
  5. either print before/after loss or write a TrainLog curve.

This module provides that loop without tying it to a particular model family.

Scope:

For dataset-backed training, use the TorchLean.Trainer API exported by NN or the shared model-zoo loader helpers.

Before/after scalar losses for a fixed-sample training run.

  • beforeLoss : α
  • afterLoss : α
Instances For
    @[implicit_reducible]
    def TorchLean.Trainer.FixedSample.steps {α : Type} [Context α] [DecidableEq Spec.Shape] [ToString α] [Runtime.FromFloat α] [Runtime.Autograd.Torch.Internal.CudaBridge.TensorConv α] {σ τ : Spec.Shape} (mkModel : nn.M (nn.Sequential σ τ)) (mkModuleDef : (model : nn.Sequential σ τ) → Runtime.Autograd.TorchLean.ScalarModuleDef (Runtime.Autograd.TorchLean.NN.Seq.paramShapes model) [σ, τ]) (mkOptim : (Floatα)(paramShapes : List Spec.Shape) → Runtime.Autograd.TorchLean.Optimizer α paramShapes) (cast : Floatα) (opts : Runtime.Autograd.Torch.Options) (sample : Sample.Supervised α σ τ) (steps : ) (cudaMemWatch : := 0) :

    One fixed-sample run for an arbitrary scalar backend.

    Instances For

      Fixed-sample run specialized to Float, returning a full per-step curve.

      Instances For