TorchLean API

NN.Examples.Quickstart.StarterWorkflow

Quickstart: Starter Workflow #

The smallest useful TorchLean training setup is ordinary model code:

import NN
open TorchLean

def model :=
  nn.Sequential![
    nn.Linear 2 8,
    nn.ReLU,
    nn.Linear 8 1
  ]

No NN.* subsystem imports are needed here. The example exercises the first workflow directly: model construction, data construction, training, evaluation, and verification all come from import NN.

Checks that KAN constructors are available from the public import NN surface.

Instances For

    Tiny in-memory regression dataset.

    The important bit is the last line: Data.tensorDataset xs ys turns ordinary Float tensors into a runtime-polymorphic dataset, so the trainer can still choose Float, executable IEEE32, CPU, CUDA, eager, or compiled execution later.

    Instances For

      Tiny adapter type example using only import NN.

      Instances For

        Run the public API example from another command or from #eval while developing.

        The shape below is the user-facing training path:

        • build the trainer from the model,
        • attach optimizer/backend choices once,
        • call trainer.eval for initial inference,
        • call trainer.train,
        • use the returned trained handle for prediction.
        • call trained.verifyRobustLInf on a small ℓ∞ box.

        The quickstart build only checks that these declarations typecheck; it does not train during ordinary lake build, which keeps CI fast.

        Instances For