TorchLean API

NN.Examples.Data.Loaders.Npy

NPY loader tutorial (NumPy/PyTorch interop) #

This tutorial shows how to train from .npy files (NumPy arrays), similar to a common PyTorch workflow where you:

  1. prepare X.npy / y.npy in Python (NumPy / PyTorch),
  2. then train a model in TorchLean by loading those files.

Generate small deterministic .npy files with python3 NN/Examples/Data/generate_toy_data.py:

Build:

The tutorial code is compiled with the rest of TorchLean. For command-line model training, use the torchlean executable examples in NN/Examples/Models.

Optional flags (tutorial-specific):

Public API used here:

A small 2-layer MLP 2 -> 8 -> 1.

Instances For

    Load the .npy tensors, print their metadata, then apply a small input transform.

    This file is intentionally interop-first: it shows the path from NumPy/PyTorch exports on disk to TorchLean's normal training API.

    Instances For