The shape of a tensor is an ordered tuple (n₁, n₂, ..., nₖ) where each nᵢ represents the size of the i-th dimension. It describes the number of elements along each dimension of the tensor.
2. Mathematical Examples by Dimensionality
2.1 Scalar (Shape: ())
Shape: ()
Example: 5
Components: Single value
2.2 Vector (Shape: (n))
Shape: (3)
Example: v=123
Basis vectors in ℝ³: e1=100,e2=010,e3=001
2.3 Matrix (Shape: (m,n))
Shape: (2,3)
Example: A=[142536]
Shape: (3,3)
Identity Matrix: I=100010001
2.4 3D Tensor (Shape: (l,m,n))
Shape: (2,2,3)
Example: T=[[142536],[710811912]]
RGB Image Example (Shape: (height, width,3)):
Shape: (2,3,3)
T=255000255000255,128000128000128
3. Mathematical Operations with Shapes
3.1 Reshaping Operations
Original shape: (4,) → vector 1234
Reshaped to (2,3) → matrix [142536]
Reshaped to (3,2) → matrix 135246
3.2 Shape Compatibility in Operations
Matrix Multiplication (A×B):
A shape: (m,n)
B shape: (n,p)
Result shape: (m,p)
Example: (2,3)×(3,2)→(2,2)
[142536]×791181012[5813964154]
3.3 Broadcasting Rules
Vector + Scalar: Shape (3,) + () → (3,)
123+4=467
Matrix + Vector: Shape (2,3) + (3,) → (2,3)
[142536]+111=[253647]
4. Special Tensor Shapes in Mathematics
4.1 Square Matrices (n,n)
Shape: (2,2)
[acbd]
Shape: (3,3)
adgbehcfi
4.2 Diagonal Matrices
Shape: (3,3)
λ1000λ2000λ3
4.3 Symmetric Tensors
This shows a symmetric matrix where the entries satisfy bij=bji .