Training Configuration #
Probes, run-configuration helpers, and per-training options for the trainer API. Command-line
parsing is available separately from NN.API.CLI.Trainer, keeping process flags out of these
configuration records.
Build a named prediction probe from a tensor.
Example:
-- Probes print a named prediction before and after the run, so training shows its movement
-- without a separate evaluation script.
def probes : Array (Trainer.Probe [2]) :=
#[Trainer.Probe.tensor "heldout" [0.25, -0.75] (inputText := "x = (0.25, -0.75)")]
Instances For
Per-training-call options for the trainer API.
steps has no default so that trainer.train data {} cannot silently perform a single update.
Example:
-- `steps` has no default on purpose: how long to train is not a library's decision.
def options : Trainer.TrainOptions :=
{ steps := 200
logEvery := 25
saveCheckpoint? := some "checkpoints/mlp.state" }
- steps : ℕ
Number of optimizer updates.
- samplesPerStep : ℕ
Number of dataset items whose gradients are accumulated into one optimizer update.
The items are processed one after another and their gradients are averaged at the same parameter point; this is gradient accumulation, not a vectorized minibatch. To run a vectorized minibatch, give the model an explicit batch axis and build the dataset with
Data.batch, whose items are already fixed-size tensor minibatches, then keep this option at1. - scheduler : Option Scheduler.Config
Optional learning-rate schedule, indexed by completed optimizer updates.
- logEvery : ℕ
Print step losses every
logEveryupdates;0disables stdout step logging. - cudaMemorySampleEvery : ℕ
CUDA allocator sampling cadence.
0uses automatic sampling for runs of at least 1000 updates and disables it for shorter runs. Non-CUDA runs do not sample the allocator. - logDestination : Training.LogDestination
Optional TrainLog artifact destination. Use
.disabledfor stdout-only runs. - logTitle : String
Title used when writing a TrainLog artifact.
Free-form notes attached to the TrainLog artifact.
- loadCheckpoint? : Option System.FilePath
Optional model-state checkpoint loaded before training; optimizer and schedule start fresh.
- saveCheckpoint? : Option System.FilePath
Optional model-state checkpoint written after training.
- reportLoss : Bool
Measure and print the evaluation-mode mean loss over the whole dataset before and after training. Each measurement is a forward pass over every sample, so large streamed datasets may turn it off; the report then records
NaNfor both losses.
Instances For
Reject option combinations that cannot describe a training run.