TorchLean API

NN.Examples.Quickstart.SimpleMlpTrain

Quickstart: Training a Small MLP #

Regression with a two-layer MLP on a synthetic grid:

  1. define the model with nn.Sequential!,
  2. build an in-memory dataset with Data.fromTensors,
  3. create a Trainer with an objective and optimizer,
  4. call trainer.train, then predict with the result.

Run:

Flags: --steps N, --seed S, --arithmetic, --execution, --device, and --show-backend.

Command name used in diagnostics and by the top-level example runner.

Instances For

    Piecewise-linear regression target 0.8 relu(x₁ + x₂) - 0.4 relu(x₂ - x₁) + 0.2.

    Instances For

      Twenty-five grid points in [-1, 1]² with their targets.

      Instances For

        Command-line help for the simple MLP quickstart.

        Instances For

          Entry point. Parses the training flags, then runs the loop; --steps defaults to 200, which is enough for the printed loss to visibly fall without the demo taking long.

          Instances For