TorchLean API

NN.Runtime.Autograd.Torch.Core.Trainer

Scalar Trainer Construction #

Allocate parameter state and build the eager trainer. The public contract is in Trainer.Types.

def Runtime.Autograd.Torch.scalarTrainer {α δ : Type} [TorchLean.Storage α] [TorchLean.Storage δ] [Context α] [TensorTransfer α] {paramShapes inputShapes dataInputShapes : List Spec.Shape} (options : Config := { }) (initRequiresGrad : Array Bool := Array.replicate paramShapes.length true) (validateDataInputs : TorchLean.TensorPack δ dataInputShapes → Except String Unit := fun (x : TorchLean.TensorPack δ dataInputShapes) => pure ()) (loss : ScalarLoss α δ paramShapes inputShapes dataInputShapes) :
Curried.Function α paramShapes (IO (ScalarTrainer α δ paramShapes inputShapes dataInputShapes))

Build a ScalarTrainer from an initial parameter pack and an operation-generic loss definition.

loss is written once against the Ops interface over a concatenated context paramShapes ++ inputShapes. Each step executes it on the autograd tape, on the CPU or on CUDA as options.device selects.

Instances For