TorchLean API

NN.Examples.Quickstart.SimpleMlpTrain

Simple MLP training example (regression) #

This is a focused end-to-end example of training a small MLP in TorchLean.

It mirrors the simplest PyTorch workflow:

  1. build a small synthetic dataset (in-memory),
  2. define an MLP (Linear -> ReLU -> Linear),
  3. train with Adam,
  4. report loss before/after, plus a few probe predictions.

Run:

Optional flags (tutorial-specific):

Regression task: model + MSE loss.

Instances For

    Small piecewise-linear regression target:

    y = 0.8 * relu(x1 + x2) - 0.4 * relu(x2 - x1) + 0.2.

    This is easy for a compact ReLU MLP to fit, which keeps the quickstart dependable.

    Instances For

      Build the training dataset at the runtime-selected scalar type α.

      We write the sample coordinates as Float literals first because they are convenient to read, and Data.supervisedDim0F lifts them into the chosen runtime scalar backend.

      Instances For