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 an ObjectiveDefinition (model + supervised loss),
  3. load or synthesize one supervised input and target,
  4. run optimizer updates on that fixed sample, and
  5. report the loss before and after training.

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 loader helpers.

def TorchLean.Trainer.FixedSample.train {α : Type} [Storage α] [Context α] [ToString α] [Runtime.FromFloat α] [Runtime.Autograd.Torch.TensorTransfer α] {σ τ : Shape} (buildModel : nn.Builder (nn.Sequential σ τ)) (buildObjective : (model : nn.Sequential σ τ) → Module.ObjectiveDefinition Unit (Runtime.Autograd.Model.Layers.Seq.stateShapes model) [σ, τ]) (buildOptimizer : (Floatα)(stateShapes : List Shape) → Runtime.Autograd.Model.Optimizer α stateShapes) (cast : Floatα) (options : Runtime.Autograd.Torch.Config) (sample : Sample.Supervised α σ τ) (steps : ) (cudaMemorySampleEvery : := 0) :

One fixed-sample run for an arbitrary scalar backend.

Instances For