Tensor Operation
In machine learning/big data we can think of a tensor as an nD-array. The picture below is an example of a rank 3 tensor with size (3,4,2).

Tensor unfolding
Unfolding a tensor to a matrix (“matrization”) is a
fundamental operation for most tensor methods and we can do it in different ways (use the tensor above as example).
Mode-1 unfolding: The column vectors of are column vectors of
Mode-2 unfolding: The row vectors of are column vectors of
Mode-3 unfolding: The mode-3 vectors of are columns vectors of
Tensor-matrix multiplication
1-mode multiplication: ( is the matrix that we need to multiply, and is the tensor we use)
(1) Mode-1 unfolding the tensor
(2) Matrix-matrix multiplication
(3) Refold (fold the matrix back to a tensor)
Same principle for mode-2 multiplication and mode-3 multiplication etc.
Outer product
Outer product between two vectors is , which is a 2D-matrix of
rank=1 .
Outer product between three vectors is a tensor with three slices, and each slice is of rank=1. Each element in the tensor: is defined by ( means i-th slice, means j-th row, means k-th column).
Frontal slices: in a tensor, the frontal slices is tensor[n, n, n], and n can be :, 0, 1, 2. : means choose all, 0 means to choose the first one, 1 means to choose the second one, and 2 means to choose the third one. The first n represents slice, the second n represents row, and the last n represents column.
1 | |
All articles in this blog adopt the CC BY-SA 4.0 agreement except for special statements. Please indicate the source for reprinting!