seegongsik
engineering mathematics

what is a tensor

Scalars, vectors, and matrices are the first rungs of the tensor ladder; the outer product makes rank-1 and a matrix is their sum

The word tensor sounds hard, but it is a name that threads things we already know onto one ladder. One cell = just a number, a scalar. A row of them is a vector, a grid is a matrix, and stacked grids are a cube. How many indexes you need is the rank. 0, 1, 2, 3. The outer product of two vectors, u⊗v = u vᵀ, builds the simplest rank-1 matrix, and any matrix can be stacked from such pieces. That was SVD. A matrix can also eat two vectors and spit out one number, uᵀ M v. One image and one training batch are both tensors. You climb the ladder one rung at a time. A cell growing into a point, a line, a face, and a block is that ladder. The grid of the outer product is the simplest matrix, and stacking color channels turns a grayscale grid into a block. The buttons raise one rung, and the board under the arrows is the number the matrix returns.

Raise the rank one rung at a time with the buttons. rank 0 is one cell, just a number. You need no index to point at a place. rank 1 stretches the cells into a row, a vector, and you need one index to pick a cell. rank 2 spreads the row into a grid, a matrix, and you need two indexes, a row and a column. rank 3 stacks those grids into a cube, so you need three indexes. The rank is the number of index axes, and that is plain to see. The shape grows with it, from a point to a line to a face to a volume. A tensor is not a new monster. It is a name that stands the things we know on one ladder.

Multiply two vectors outward and you get a matrix. With the sliders, put u = (u1, u2) down the left and v = (v1, v2) across the top, and cell (i, j) holds ui · vj. That is u⊗v = u vᵀ. The number in a cell is the left value times the top value, and the cell is painted darker or lighter with that value. Grow u and the whole row grows. Grow v and the whole column grows. However you turn them, the rank of this matrix is always 1. Every row is a multiple of u and every column is a multiple of v, so there is only one independent direction. The outer product is the simplest matrix, a rank-1 brick.

An ordinary matrix is several rank-1 bricks stacked. A button adds one layer at a time. Layer 1 is only the first piece σ1·u1·v1ᵀ, so it sketches only the coarse outline of the target. Add layer 2 and σ2·u2·v2ᵀ fills the remaining gap, and the sum matches the target. The screen shows the reconstruction and the target side by side, and the difference as a number. That is the heart of SVD. Any matrix is A = Σ σk uk vkᵀ, a sum of rank-1 pieces, and keeping only the largest few σ leaves most of the shape. Compression comes from here. Keeping the largest pieces is how an image shrinks without losing its shape.

A matrix can be a machine that eats two vectors, not only a transformation. Feed u on the left and v on the right of a fixed matrix M and one number comes out, uᵀ M v. That is a rank 2 tensor, a matrix, taking two vectors and returning a scalar, a bilinear form. Drag the arrows u and v on the plane and the board below shows uᵀ M v at once. Fix one and grow the other, and the result grows by the same factor. It is linear in each argument, so it is bilinear. The inner product that measures length, the energy ½ xᵀ K x, curvature, and stress, anything that eats two directions and returns one number, sit in this frame.

Last, why a tensor is the everyday container of machine learning. A button adds one axis at a time. One grayscale image is a grid of pixel brightness, the matrix [H, W], rank 2. Add color and the red, green, and blue channels stack into the cube [H, W, 3], rank 3. Train on several images at once and those cubes stack N deep into [N, H, W, 3], rank 4. The screen shows the shape label and how the grid stacks as you add an axis. A tensor is not decoration. It is a practical bowl for the several axes of data. That is why the name Tensor sits inside deep-learning frameworks.

In PracticeA tensor is the name that stands numbers, vectors, matrices, and cubes on one ladder. The number of index axes is the rank, so a scalar = 0, a vector = 1, a matrix = 2, and a cube = 3. The outer product u⊗v = u vᵀ fills cell (i,j) with ui·vj and builds the simplest rank-1 matrix, and any matrix is A = Σ σk uk vkᵀ, a sum of rank-1 pieces. That is SVD, and keeping only the large σ is compression. Write a matrix as a bilinear form and uᵀ M v eats two vectors and returns one number, linear in each, so inner products, energy, and stress share the frame. The data of machine learning is a tensor all the way through. A grayscale image [H,W], color [H,W,3], a batch [N,H,W,3]. Climb from number to vector to matrix to cube and linear algebra is one ladder.
← engineering mathematics
Was this helpful? Support seegongsik