TList #
TList / supervised-sample ergonomics.
TorchLean uses dependently-typed heterogeneous lists (TList α ss) to keep tensor shapes aligned
with the type-level list ss.
This is great for safety, but raw .cons ... pattern matching is noisy in tutorials. This module
provides small tuple-like accessors and constructors so end-user code can stay readable.
PyTorch Mapping #
PyTorch typically represents multi-tensor samples as plain tuples (x, y, ...).
TList plays a similar role, but with the extra benefit that each component's shape is tracked in
the type, so "wrong order" bugs become type errors.
Small ergonomics for TorchLean's typed tensor lists (TList).
TList α ss is a heterogeneous list of tensors whose shapes are tracked by the type-level list
ss.
It is great for safety, but raw destructuring via .cons ... is noisy in demos.
This namespace provides the small "get/unpack" helpers you would expect from tuple-like samples.
Typed tensor lists, used throughout TorchLean as shape-tracked tuples of tensors.
Instances For
Construct a 1-element TList (like a 1-tuple).
Instances For
Construct a 2-element TList (like a pair).
Instances For
Construct a 3-element TList (like a 3-tuple).
Instances For
Construct a 4-element TList (like a 4-tuple).
Instances For
Map each tensor entry (shape-preserving).
Instances For
Zip two TLists pointwise (shape-preserving).
Instances For
First element of a non-empty TList (0-indexed).
Instances For
Second element of a TList with at least two entries (0-indexed).
Instances For
Third element of a TList with at least three entries (0-indexed).
Instances For
Fourth element of a TList with at least four entries (0-indexed).
Instances For
Tail of a non-empty TList (drop the first element).
Instances For
Unpack a length-1 TList into its element.
Instances For
Unpacking mk1 yields the original element.
Unpack a length-2 TList into a Lean pair.
Instances For
Unpacking mk2 yields the original pair.
Unpack a length-3 TList into a Lean triple.
Instances For
Unpacking mk3 yields the original triple.
Unpack a length-4 TList into a Lean 4-tuple.
Instances For
Unpacking mk4 yields the original 4-tuple.
Ergonomics for the common supervised-learning sample shape TList α [xShape, yShape].
This keeps tutorial code closer to the PyTorch convention of (x, y) pairs without losing
TorchLean's static shape safety.
A supervised sample (x, y) with input shape σ and target shape τ.
Instances For
A fixed-size minibatch of supervised samples.
Instances For
Build a supervised sample (x, y) represented as TList α [σ, τ].
Instances For
Build a batched supervised sample (xBatch, yBatch) for a minibatch of size n.
Instances For
Extract the input tensor x from a supervised sample.
Instances For
Extract the target tensor y from a supervised sample.
Instances For
Map a function over the input tensor x, leaving the target y unchanged.
Instances For
Map a function over the target tensor y, leaving the input x unchanged.
Instances For
Map functions over both x and y in a supervised sample.