Tensor Datasets #
Conversion between leading-axis tensors, tensor packs, and runtime datasets.
TensorDataset (leading-axis batching) #
PyTorch's TensorDataset concept is: given one or more tensors that share the same size(0),
build a dataset of samples by slicing each tensor along its leading batch axis.
In TorchLean we do the same thing, but with shapes tracked in the type:
- a batched tensor has shape
.dim n σ, - slicing at
i : Fin nyields a sample of shapeσ, - and a batch of multiple tensors is represented as a
TensorPack.
Slice a batched TensorPack along its leading batch axis.
If a sample is represented as a shape-indexed tuple TensorPack β ss, then a minibatch of size n
is TensorPack β (ss.map (fun s => .dim n s)). This function picks a batch index i : Fin n and returns
the corresponding single sample.
Instances For
Convert a shape-indexed TensorPack of Float tensors to the runtime scalar type α.
Instances For
Build a dataset by slicing a batched TensorPack along the leading batch axis. This gives the
typed counterpart of a tensor dataset built from several aligned arrays.
Instances For
Float-to-α variant of tensorDatasetFromLeadingAxis, for data loaded from disk.
Instances For
Supervised dataset from two batched tensors X : (n, σ) and Y : (n, τ) by slicing the leading batch axis.
This is the common regression/supervised-learning case: the TorchLean analogue of
TensorDataset(X, Y) in PyTorch.
Instances For
Float-to-α variant of supervisedFromLeadingAxis, for data loaded from disk.