Tensor decomposition and applications - study notes [01]

0. Introduction

This note is mainly carried out around this academic journal articles are:

Tensor Decomposition and Applications

The first step in this notebook is in contact with the author in the field, the most suitable friend never touched the field.

We hope to initiate attract more fans.

How will the future tensor cut deep learning and strengthen aspects of learning areas such as research and discussion. I hope this long can stick to it.

If the correspondence is defined temporarily unable to find Chinese name, the direct use of English. Forget understanding. (Anyway, write literature, it also must be in English thing)

1 Introduction

  • What is tensor (tensor)? Simply put, it is a multi-dimensional array. Within the scope of this study, does not consider any tensor is defined in the physical and engineering fields, but only to consider the field of mathematics. The official said the amount should be called Zhang domain (tensor fields). A first tensor (first-order tensor) is a vector (vector), a second-rank tensor (second-order tensor) is the matrix (matrix), more rank tensor we call the higher order tensor (IN AREAS OF COMMUNICAITIONS -order tensor).
  • An amount of a simple 3 shown in FIG lower order tensor. Note \ (i \) is what we usually think of \ (y \) axis, the index is not starting from 0, starting at 1. 1 place to start is also noteworthy. Although this is not what is important reasoning impact, but will affect the results of some examples of the order and later formula.

A simple third-order tensor FIG.

  • Enabling the following general font set in the next article. Lowercase bold letters e.g. x a representative vector, capital bold letters X representative of the matrix, squiggles \ (\ mathcal {X} \ ) representative of tensor.

2. Basic definitions

2.1 Fiber and Slice

  • 当我们将一个张量沿着他的第k个维展开的时候,我们就获得了mode-k fiber。例如,三阶张量 \(\mathcal{X}\) 的mode-1 fiber为:\(X_{:jk}\)。换句话说,所有维度的index都维持不变,除了第k个维度被展开。
  • 同理,当我们除了2个维度展开以外维持所有index不变时,我们就获得了slice。例如,三阶张量 \(\mathcal{X}\) 的horizontal slice为:\(X_{i::}\)。最为常用的slice为下图第二行第三个的frontal slice\(X_{::k}\)。我们常常可以缩写为\(X_k\)。请务必牢记。

Slice of the original fiber and FIG feature

2.2 Norm 范数 与 inner product内积

  • 张量norm的定义和矩阵范数的定义类似,均为所有元素的平方之和开根。对于张量 \(\mathcal{X} \in\mathbb{R}^{I_1 \times I_2 \times \dots \times I_N}\)来说:

\[||\mathcal{X}|| = \sqrt{\sum_{i1=1}^{I_1}\sum_{i2=1}^{I_2}\dots\sum_{iN=1}^{I_N}x^2_{i_1i_2\dotsi_N}} \]

  • 类似的,我们定义内积为2个维度相等的张量之间对应位置元素之积的和。这和矩阵定义是类似的。对于张量 \(\mathcal{X}, \mathcal{Y} \in\mathbb{R}^{I_1 \times I_2 \times \dots \times I_N}\)来说:

\[\langle\mathcal \:{X}, \:\mathcal{Y} \: \rangle = \sqrt{\sum_{i1=1}^{I_1}\sum_{i2=1}^{I_2}\dots\sum_{iN=1}^{I_N}x^2_{i_1i_2\dotsi_N}} \]

  • 显然,\(\langle\mathcal{X},\:\mathcal{X}\rangle = ||X||^2\)

2.3 Rank-One Tensors 秩1张量

  • 即使范数和内积与矩阵类似,我们要对秩(rank)万分小心。后面我们马上会提到这是个非常棘手的概念。我们很多时候无法轻易地决定一个张量的秩是多少。 不过,秩1张量比较特别。他可以被向量(vector)的外积(outer product)所定义。
  • 对于一个N阶张量 \(\mathcal{X} \in\mathbb{R}^{I_1 \times I_2 \times \dots \times I_N}\)来说,当可以被写成N个向量的外积时,此张量的秩为1:

\[ \mathcal{X} = a^{(1)} \circ a^{(2)} \circ \dots \circ a^{(N)} \]

  • \(\circ\) 是外积的符号。每个张量的元素都可以被写成这些向量对应位置元素之积:

    \[ x_{i_1i_2\dots i_N} = a^{(1)}_{i_1} \circ a^{(2)}_{i_2} \circ \dots \circ a^{(N)}_{i_N} \]

2.4 cubical 立方,Symmetry 对称 与 Supersymmetric 超对称

  • 当张量的所有维度大小相等时,我们称之为立方(cubical)。
  • 当立方张量中的任何一个元素的index被置换后(permutation)元素值不变时,我们称这个张量为超对称。
  • 例:对于3阶张量\(\mathcal{X} \in\mathbb{R}^{I \times I \times I}\)来说,如果满足以下等式,则被称之为超对称。

\[x_{ijk} = x_{ikj} = x_{jik} = x_{jki} = x_{kij} = x_{kji} \quad \text{ for all $ i, j, k = 1,\dots,I.$}\]

  • 张量在某些mode下符合对称的条件, 这时候我们只叫他在
    对应的mode下对称。例如,3阶张量\(\mathcal{X} \in\mathbb{R}^{I \times I \times K}\) 的frontal slice对称时,我们称该张量在mode 1和2之下对称。(这里有些拗口,可以理解为,展开1和2的情况,固定剩余维度的情况下,所获得的的slice是对称的)

\[ X_k = X_k^T \quad \text{ for all $ k = 1,\dots,K.$} \]

2.5 Diagonal Tensors 对角张量

  • 如果一个张量\(\mathcal{X} \in\mathbb{R}^{I_1 \times I_2 \times \dots \times I_N}\)的任何元素只有在\(i_1 \: = \: i_2 \: = \: \dots \: = i_N\)的时候不为0,也就是\(x_{i_1i_2 \dots i_N} \neq 0\)时,被称之对角张量。
  • 如果对角张量同时是立方的,则只有超对角线(superdiagonal)所经过的元素不为0
  • 值得注意的是,对角张量对任何维度比例的张量其实都成立。

2.6 Matricization 矩阵化

  • 矩阵化讲述了如何将高维张量拆解成2阶的矩阵。这是个极为重要的概念,日后将频繁出现在各种公式与定理之中。其文字化定义意外的简单,而数学定义较为繁琐。
  • 文字化定义:对于张量\(\mathcal{X} \in\mathbb{R}^{I_1 \times I_2 \times \dots \times I_N}\)来说,我们称其mode-n的矩阵化为 $ X_{(n)}\(。通过把\)\mathcal{X} $的每一根mode-n fiber按序插入这个矩阵的列中,我们就完成了矩阵化。
  • 数学定义必须定义其顺序所以稍显复杂。我们定义一个从张量元素\((i_1, i_2, \dots , i_N)\)到矩阵元素\((i_n, j)\)的映射:

\[ j \: = \: 1 + \sum_{k=1 \\ k\neq n} ^N (i_k-1)J_k \quad \text{ with } \quad J_k = \prod_{m=1\\m\neq n}^{j-1} I_m.\]

  • 例:假设某张量\(\mathcal{X} \in \mathbb{R}^{3 \times 4 \times 2}\)的frontal slices如下:

\[\begin{equation} X_1 = \begin{bmatrix} 1 & 4 & 7 & 10 \\ 2 & 5 & 8 & 11 \\ 3 & 6 & 9 & 12 \end{bmatrix} \text{,}\quad X_2 = \begin{bmatrix} 13 & 16 & 19 & 22 \\ 14 & 17 & 20 & 23 \\ 15 & 18 & 21 & 24 \end{bmatrix} \end{equation}.\]

  • 运用文字化定义,我们能很快的获得其3个mode下的矩阵化结果。如果你想挑战数学定义,你可能需要一个笔记本或者一段代码.

\[ X_{(1)} = \begin{bmatrix} 1 & 4 & 7 & 10 & 13 & 16 & 19 & 22 \\ 2 & 5 & 8 & 11 & 14 & 17 & 20 & 23 \\ 3 & 6 & 9 & 12 & 15 & 18 & 21 & 24 \end{bmatrix}, \]

\[ X_{(2)} = \begin{bmatrix} 1 & 2 & 3 & 13 & 14 & 15 \\ 4 & 5 & 6 & 16 & 17 & 18 \\ 7 &8 & 9 & 19 & 20 & 21 \\ 10 & 11 & 12 & 22 & 23 & 24 \end{bmatrix}, \]

\[ X_{(3)} = \begin{bmatrix} 1 & 2 & 3 & 4 & 5 & \dots & 9 & 10 & 11 & 12 \\ 13 & 14 & 15 & 16 & 17 & \dots & 21 & 22 & 23 & 24 \end{bmatrix}.\]

  • 注意:不同的论文有时会在展开(unfold)时使用完全不同的排序方法。只要这些排序方法是前后统一的,一般来说不会给理论及计算带来影响。顺便,如果以本文的顺序来定义向量化的话。则为以下形式。

\[ \mathbb{vec}(\mathcal{X}) = \begin{bmatrix} 1 \\ 2 \\ \vdots \\ 24 \end{bmatrix}.\]

2.7 Tensor Multiplication: The n-Mode Product 张量乘法之n-Mode乘积

  • 定义了上述概念后,我们终于可以定义张量乘法了。就像是矩阵乘法有其特别算法一样,张量也有类似的算法,只是更为复杂。本文将不会叙述一个完整的张量乘法定义,而是仅挑选其最为有意义的n-mode乘法来进行介绍。也就是张量与矩阵(或向量)在mode n之下的乘积。
  • 张量\(\mathcal{X} \in\mathbb{R}^{I_1 \times I_2 \times \dots \times I_N}\)与矩阵\(\mathrm{U} \in \mathbb{R} ^{J \times I_n}\)的mode-n乘积我们写作\(\mathcal{X} \times_n U\)
    其维度大小为 \(I_1 \times \dots \times I_{n-1} \times J \times I_{n+1} \times \dots \times I_N.\)。其每个元素可被写为:

\[(\mathcal{X} \times_n \mathrm{U})_{i_1\dots i_{n-1}ji_{n+1}\dots i_N} = \sum_{i_n = 1 } ^{I_n} x_{i_1i_2\dots i_N} \: u_{ji_n}. \]

  • 笔者是这么理解这个公式的:将没有选中的维度所组成的索引集为行,选中的维度展开为列,形成的矩阵与U相乘,便是n-mode张量乘法的结果。这个矩阵列就是之前矩阵化时所提到的,每个列都是原始张量的mode-n fiber。例如,对于一个\(5 \times 3 \times 2\)的张量与\(2\times 9\)的矩阵相乘,我们可以看做张量被矩阵化(此例为mode-3 因为只有第三个维度才可以和矩阵相乘)为\(5 \times 3 = 15\)行。这个15也就是除去被选中进行乘法的维度以外的剩余维度可索引元素最大数量。最后该矩阵乘法的结果为一个矩阵。这是我们原本所期待的张量乘积的n-mode矩阵化后的产物。由于多维索引被我们压缩在一起变成了行,为了还原张量结果,我们需要还回这些索引到本来的位置,于是便获得了真正的乘积\(\mathcal{Y}\)。用数学语言来说,便是如下等式:

\[ \mathcal{Y} = \mathcal{X} \times_n \mathrm{U} \quad \Leftrightarrow \quad Y_{(n)} = \mathrm{UX}_{n}.\]

  • 再来一个具体的例子吧。令 \(\mathcal{X}\) 为2.6例子中的张量,令 \(\mathrm{U} = \begin{bmatrix} 1 & 3 & 5 \\ 2 & 4 & 6 \end{bmatrix}.\) 则他们的乘积\(\mathcal{Y} = \mathcal{X} \times_1 \mathrm{U} \in \mathbb{R}^{2 \times 4 \times 2}\)为:

\[ \mathrm{Y}_1 = \begin{bmatrix}22 & 49 & 76 & 103 \\ 28 & 64 & 100 & 136 \end{bmatrix} , \quad \mathrm{Y}_2 = \begin{bmatrix} 130 & 157 & 184 & 211 \\ 172 & 208 & 244 & 280 \end{bmatrix}.\]

2.8 Properties of Mode-n Product 矩阵乘法的性质

  • 当张量和多个矩阵进行不同mode的连续相乘时,乘法的顺序和结果无关:

\[ \mathcal{X} \times_m \mathrm{A} \times_n \mathrm{B} = \mathcal{X} \times_n \mathrm{B} \times_m \mathrm{A} \quad\text{ $(m \neq n)$}.\]

  • 当mode相同时,存在以下特性:

\[ \mathcal{X} \times_n \mathrm{A} \times_n \mathrm{B} = \mathcal{X} \times_n (\mathrm{B} \mathrm{A}).\]

  • 张量$\mathcal{X} \in\mathbb{R}^{I_1 \times I_2 \times \dots \times I_N} $ 与 向量 \(\mathrm{v} \in \mathbb{R}^{I_n}\)的n-mode乘法写作 \(\mathcal{X} \: \bar\times_n \: \mathrm{v}.\)
    对每个元素来说下式成立。

\[ (\mathcal{X} \: \bar\times_n \: \mathrm{v})_{ i_1 \dots i_{n-1} i_{n+1}\dots i_N } = \sum_{i_n = 1}^{I_n} x_{i_1 i_2 \dots i_N} \: v_{i_n}.\]

  • 因此,和向量的mode-n相乘等同于\(\mathcal{X}\)的每一根mode-n fiber与向量\(\mathrm{v}\)的内积。由于内积塌缩了这个维度,使得他的大小只有1,在这里我们选择泯灭了这个mode-n所对应的维度,使得结果必然为\(N-1\)阶。(在深度学习模型中,有很多时候我们能看到(1,64,64,4)之类的张量。对应了图片数量,尺寸,颜色等。显然笔者认为我们也可以定义另一种mode-n乘法使得结果变为\(\mathbb{R}^{i_1 \times \dots i_{n-1} \times \:\mathrm{1} \:\times i_{n+1}\times \dots \times i_N}\)。只是在本文的讨论范畴内,此选择是没有必要的。)
  • \(\mathcal{X}\) 还是为2.6例子中的张量, 设 \(\mathrm{v} = \begin{bmatrix} 1 & 2 & 3 & 4 \end{bmatrix}^T\),则

\[ \mathcal{X} \: \bar\times_2 \: \mathrm{v} = \begin{bmatrix} 70 & 190 \\ 80 & 200 \\ 90 & 210\end{bmatrix}. \]

  • 由于mode-n向量乘法在定义里面减去了1个维度,这使得张量的连续向量乘法中,乘法的优先顺序变得很重要。换句话说,下列等式将成立:

\[ \mathcal{X} \: \bar\times_m \: \mathrm{a} \: \bar\times_n \: \mathrm{b} = (\mathcal{X} \: \bar\times_m \: \mathrm{a}) \bar\times_{n-1} \: \mathrm{b} = (\mathcal{X} \: \bar\times_{m} \mathrm{b}) \: \bar\times_m \: \mathrm{a} \quad \text{ for $\:m<n$} .\]

After this period is over, the next issue will first review the Kronecker matrix, Khatri-Rao and Hadamard multiplication concepts, continue to introduce basic properties of tensor. Welcome everyone's attention!

Guess you like

Origin www.cnblogs.com/lywangjapan/p/12041658.html