Training #
The main training interface:
let trainer := Trainer.new model
{ objective := mse
optimizer := optim.adam { lr := 0.03 } }
let y0 ← trainer.predict x
let trained ← trainer.train data { steps := 200, samplesPerStep := 16, logEvery := 25 }
trained.printSummary
trained.save "model.state"
The same interface supports regression, classification, custom losses, finite datasets, and
streaming batches. The runtime-selected entry points use Tensor Float; the run executes in the
binary32 scalar selected by arithmetic (Float32 or ExecFloat.Binary 8 23) and the report names
it. For a chosen scalar α, trainer.openTyped (α := α) opens a CPU session that retains α in
inputs, parameters, losses, predictions, and checkpoints.
Programs that own the optimizer loop open the same trainer as a session:
let session ← trainer.open
for step in [0:steps] do
let loss ← session.step (sampleAt step) (loss := true)
let trained ← session.finish { before, after }
trainer.train is exactly this pattern with dataset cycling, logging, and checkpoints added.