✦ For everyone, free.

Practical knowledge for real and everyday life

Home

7.4.1 Tensor Component Array Shape

Tensor Component Array Shape describes how tensor components are arranged in multidimensional arrays, reflecting their rank and index structure.

Tensor Component Array Shape is the ordered list of axis lengths that describes how many entries a tensor's component array holds along each of its index positions, fixing the size and dimensionality of the array independently of the specific numerical values stored inside it.


Definition and Scope

Shape as a Tuple of Axis Lengths

For a tensor of type ((p,q)) on an (n)-dimensional vector space, the array shape is the tuple

shape = ( n,n,,n )

with exactly (p+q) entries, one per index, each equal to (n) when every index ranges over a common-dimensional space; if the tensor's upper and lower indices instead ranged over spaces of different dimensions, the corresponding entries of the shape would differ accordingly.

Rank as the Length of the Shape

The number of entries in the shape tuple is the rank of the tensor: a rank-0 tensor has the empty shape (()), a rank-1 tensor has a one-entry shape ((n)), a rank-2 tensor has a two-entry shape ((n,n)), and so on, with the rank recoverable directly by counting the entries of the shape rather than by any other property of the array.


Structural Properties

Total Entry Count

The shape determines, but is not identical to, the total number of scalar entries in the array, obtained by multiplying its entries together:

total entries = k=1p+q nk

so that a rank-3 tensor with shape ((n,n,n)) has (n^3) total entries, a count that grows rapidly with both rank and dimension.

Shape Compatibility in Operations

Certain tensor operations require matching shapes before they are defined. Adding two tensors entry by entry is only meaningful when both share the same shape, while a tensor product concatenates the shapes of its two factors, and a contraction removes one entry from each of the two matched axes, shrinking the shape by two positions.

shape (n,n) shape (n) = shape (n,n,n)

Distinguishing Shape From Symmetry

Shape describes only the size of each axis, not the relationships among entries. Two tensors can share the same shape, ((n,n)) for a rank-2 tensor, while differing entirely in symmetry, one fully symmetric and the other with no symmetry at all, since symmetry is a further constraint layered on top of the shape rather than encoded within it.


Role Within Tensor Algebra

Reshaping and Reinterpretation

Because a fixed total number of entries can often be arranged into several different shapes, the same underlying flat data can be reinterpreted under a different shape, a rank-2 array of shape ((n^2, 1)) alongside a rank-1 array of shape ((n^2)) holding the same values in the same order, a technique used to move between different but numerically equivalent representations of stored data.

Validation in Computation

Checking array shape before performing an operation is a standard first step in tensor computation, since a shape mismatch signals immediately that two arrays cannot represent compatible tensors for the intended operation, without requiring inspection of the individual component values to detect the incompatibility.