TorchLean API

NN.API.Tensor.Views

Tensor Views (API) #

Small, shape-preserving tensor views that show up across examples and subsystems.

These helpers are deliberately model-agnostic:

Flattened Prefix View #

For quick experiments, it's often useful to treat an arbitrary source shape as a flattened feature vector and keep only the first takeDim coordinates. This keeps runnable demos fast without baking dataset-specific flattening logic into every example.

def NN.API.tensor.flattenBatchPrefix {α : Type} [Inhabited α] (batch takeDim : ) {source : Shape} (hTake : takeDim Shape.size source) (x : Spec.Tensor α (Spec.Shape.dim batch source)) :
Spec.Tensor α (Tensor.Shape.Mat batch takeDim)

Flatten each sample in a batch and keep the first takeDim entries.

The output is a typed matrix batch × takeDim.

Instances For