TorchLean API

NN.API.Trainer.Manual.Stepper

Runtime Supervised Training #

Supervised tasks, runners, steppers, optimizer configs, trainer aliases, and the low-level session exports that back executable examples.

Stateful training steps #

structure TorchLean.Trainer.Manual.Stepper (α : Type) [Context α] [DecidableEq Spec.Shape] {σ τ : Spec.Shape} (task : SeqTask σ τ) :

Stateful training loop object: a Runner plus an optimizer state and a step counter. It packages the model runner with the state needed to step on successive batches.

Instances For
    def TorchLean.Trainer.Manual.stepper {σ τ : Spec.Shape} {task : SeqTask σ τ} {α : Type} [Context α] [DecidableEq Spec.Shape] [ToString α] [Runtime.FromFloat α] (runner : Runner α task) (optimizer : OptimizerConfig) (scheduler : Option Scheduler.Config := none) :
    IO (Stepper α task)

    Construct a Stepper for a runner, optimizer config, and optional scheduler.

    This is the recommended way to build custom training loops without reimplementing the optimizer logic: call stepper, then choose stepSample for single batches or epochSamples for explicit sample lists.

    Instances For
      def TorchLean.Trainer.Manual.step {σ τ : Spec.Shape} {task : SeqTask σ τ} {α : Type} [Context α] [DecidableEq Spec.Shape] (loop : Stepper α task) (sample : Runtime.Autograd.Torch.TList α [σ, τ]) :
      IO α

      Run one optimization step on a single supervised sample.

      Instances For
        def TorchLean.Trainer.Manual.epoch {σ τ : Spec.Shape} {task : SeqTask σ τ} {α : Type} [Context α] [DecidableEq Spec.Shape] (loop : Stepper α task) (samples : List (Runtime.Autograd.Torch.TList α [σ, τ])) :
        IO (List α)

        Run one epoch over a list of supervised samples, returning the per-step losses.

        Instances For