TorchLean API

NN.API.Data.Synthetic

Synthetic Data #

This module provides deterministic tabular grids used by examples and tests. Domain-specific datasets and sample packing belong in their respective data modules.

Tabular grids #

def TorchLean.Data.Synthetic.cartesianGrid {α : Type} [Storage α] [Zero α] {m n : } (xCoordinates : Tensor α [m]) (yCoordinates : Tensor α [n]) :
Tensor α [m * n, 2]

Cartesian product of two vectors (batched tensor of points).

cartesianGrid xCoordinates yCoordinates produces a tensor X : (m*n, 2) containing all pairs (x, y) with:

  • x taken from xCoordinates : (m,)
  • y taken from yCoordinates : (n,)

Ordering is row-major: for each x in xCoordinates (outer loop), we sweep all y in yCoordinates (inner loop).

PyTorch analogue: torch.cartesian_prod(xCoordinates, yCoordinates) (up to shape).

Instances For
    def TorchLean.Data.Synthetic.linspace {α : Type} [Storage α] [Context α] (lower upper : α) (count : ) :
    Tensor α [count]

    Linearly spaced points including endpoints.

    linspace lo hi count returns a vector tensor of shape (count,):

    • empty if count = 0
    • [lo] if count = 1
    • otherwise count points from lo to hi (inclusive).

    PyTorch analogue: torch.linspace.

    Instances For
      def TorchLean.Data.Synthetic.squareGrid {α : Type} [Storage α] [Context α] (lower upper : α) (count : ) :
      Tensor α [count * count, 2]

      Square grid over [lower, upper] x [lower, upper].

      Instances For