Tensor Operations #
This example continues after NN.Examples.Quickstart.TensorBasics. It shows indexing, einsum,
batch axes, reshaping, elementwise operations, and editor widgets on the same shape-indexed tensor
type used by models and specifications.
Build with lake build NN.Examples.DeepDives.TensorOperations, then inspect the
#tensor_view commands in the editor. This module has no command-line entry point.
Construction and indexing #
A matrix literal. Its element type and both dimensions are visible in the type.
Instances For
Selecting one coordinate on the leading axis returns a tensor of the remaining shape.
Instances For
Linear algebra #
A 4 × 3 parameter tensor.
Instances For
A three-component input vector.
Instances For
Matrix multiplication preserves the output dimension in the result type.
Instances For
Batches and reshaping #
Two 2 × 3 samples stacked along a leading batch axis.
Instances For
Indexing a rank-three tensor drops the outer axis, giving a [2, 3] matrix.
Instances For
The second batch element, same shape.
Instances For
A flat tensor whose values will be viewed at another shape.
Instances For
Reshape a vector without changing row-major element order.
Instances For
Shape-preserving transformations #
A constant matrix of twos for the elementwise addition example.
Instances For
A constant matrix of threes; adding it to tensorA produces a matrix of fives.
Instances For
Ordinary + on tensors is elementwise, and the shapes must already agree.
There is no implicit broadcasting here: a shape mismatch is a type error, not a runtime surprise.
Instances For
A pointwise transformation has the same shape discipline as a gradient buffer.