2021-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜ํ†ต๊ณ„์  ๋ฐ์ดํ„ฐ๋งˆ์ด๋‹โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)

7 minute read

2021-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜ํ†ต๊ณ„์  ๋ฐ์ดํ„ฐ๋งˆ์ด๋‹โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)

Set-up


formulas.

1. $\displaystyle UU^T = \sum^n_{i=1} \mathbf{u}_i \mathbf{u}_i^T$, where $U = \left( \mathbf{u}_1, \dots, \mathbf{u}_n \right) \in \mathbb{R}^{n \times n}$

2. $\displaystyle UDU^T = \sum^n_{i=1} d_i \mathbf{u}_i \mathbf{u}_i^T$, where $D = \text{diag}(d_i)$

ํ–‰๋ ฌ๊ณฑ์„ ํ‘œํ˜„ํ•˜๋Š” ์œ ์šฉํ•œ ๋ฐฉ์‹์ด๋‹ˆ ์ต์ˆ™ํ•ด์ง€๋ฉด ์ข‹๋‹ค! ์•ž์œผ๋กœ ๋‚˜์˜ค๋Š” ๋‚ด์šฉ์—์„œ ์ž์ฃผ ๋“ฑ์žฅํ•œ๋‹ค!


Definition. Orthogonal Matrix

An <orthogonal matrix> $U$ is a matrix such that $UU^T = U^TU = I_n$.


Spectral Decomposition


Theorem. Spectral Decomposition; Eigen Decomposition

For a real symmetric matrix $A \in \mathbb{R}^{n\times n}$, there exists a diagonal matrix $D = \text{diag}(d_1, \dots, d_n)$ and an orthogonal matrix $U$ s.t. $A = UDU^T$.

์ฆ‰, ๋ชจ๋“  symmetric matrix๋Š” $UDU^T$์˜ ํ˜•ํƒœ๋กœ decompose ๊ฐ€๋Šฅํ•จ์„ ๋งํ•œ๋‹ค!


Note.

  • Each $d_i$ is an real eigenvalue of $A$.
  • $\mathbf{u}_i$ is the eigenvector associated with $d_i$, where $U = \left( \mathbf{u}_1, \dots, \mathbf{u}_n \right)$.
  • $\displaystyle A = UDU^T = \sum^n_{i=1} d_i \mathbf{u}_i \mathbf{u}_i^T$

<Spectral Decomposition>์€ ๊ธฐํ•˜ํ•™์  ์ดํ•ด๊ฐ€ ์ˆ˜๋ฐ˜๋˜์–ด์•ผ ํ•œ๋‹ค.

๋จผ์ €, orthogonal matrix $U$์— ๋Œ€ํ•ด $U$๋Š” ์„ ํ˜•๋ณ€ํ™˜์—์„œ ์ผ์ข…์˜ rotation matrix์˜ ์—ญํ• ์„ ํ•œ๋‹ค.

\[\mathbf{x} \longrightarrow U \mathbf{x}\]

์ด์ œ $A\mathbf{x}$๋ฅผ ํ•ด์„ํ•˜๊ธฐ ์œ„ํ•ด $UDU^T\mathbf{x}$๋ฅผ ๋‹จ๊ณ„๋ณ„๋กœ ํ•ด์„ํ•ด๋ณด์ž.

1. $U^T \mathbf{x}$; ํšŒ์ „์„ ํ†ตํ•ด ์ขŒํ‘œ์ถ• ๋ณ€ํ™˜

$U^T$๋Š” ํšŒ์ „ ๋ณ€ํ™˜์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. ๋”ฐ๋ผ์„œ, $e_1$, $e_2$ ์ขŒํ‘œ๊ณ„ ์œ„์— ์žˆ๋˜ $\mathbf{x}$๋ฅผ $u_1$, $u_2$ ์ขŒํ‘œ๊ณ„๋กœ ํšŒ์ „ ๋ณ€ํ™˜ํ•œ๋‹ค.

์ด๋•Œ, $u_1$, $u_2$๋Š” $U^T$์˜ ๊ฐ ์—ด์œผ๋กœ์จ $A$์˜ eigen vector์ด๋‹ค.

๊ทธ๋ฆฌ๊ณ  $U^T \mathbf{x}$๋ฅผ ๊ณ„์‚ฐํ•ด๋ณด๋ฉด,

\[U^T \mathbf{x} = \left(u_1, u_2 \right) \cdot \mathbf{x} = \begin{pmatrix} (\mathbf{x}^T u_1) \cdot u_1 \\ (\mathbf{x}^T u_2) \cdot u_2 \end{pmatrix}\]

๊ฐ€ ๋˜๊ณ , ์ด๊ฒƒ์€ $\mathbf{x}$๋ฅผ $u_1$, $u_2$ ์ถ•์œผ๋กœ <projection>ํ•œ ๊ฒƒ๊ณผ ๊ฐ™๋‹ค.

2. $D \left( U^T \mathbf{x} \right)$; ์Šค์นผ๋ผ ๊ณฑ

$D$๋Š” diagnomal matrix์ด๊ธฐ ๋•Œ๋ฌธ์— $u_1$, $u_2$ ๋ฐฉํ–ฅ์˜ ๋ฒกํ„ฐ์— ๋Œ€ํ•œ ์Šค์นผ๋ผ ๊ณฑ์„ ํ•˜๋Š” ์—ญํ• ์ด๋‹ค.

3. $U \left( D U^T \mathbf{x} \right)$; ์›๋ž˜์˜ ์ขŒํ‘œ์ถ•์œผ๋กœ ์—ญ-ํšŒ์ „

๋งˆ์ง€๋ง‰์œผ๋กœ ์ฒ˜์Œ์— ๊ณฑํ•œ $U^T$์˜ ์—ญ-ํšŒ์ „ ๋ณ€ํ™˜์ธ $U$๋ฅผ ์ ์šฉํ•ด ๋‹ค์‹œ $e_1$, $e_2$์˜ ์ขŒํ‘œ๊ณ„๋กœ ๋˜๋Œ๋ ค ์ค€๋‹ค.

๊ทธ๋ž˜์„œ ์‹์„ ์ •๋ฆฌํ•˜๋ฉด, ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

\[UDU^T \mathbf{x} = UD \begin{pmatrix} u_1^T \mathbf{x} \\ \vdots \\ u_n^T \mathbf{x} \end{pmatrix} = U \begin{pmatrix} d_1 u_1^T \mathbf{x} \\ \vdots \\ d_n u_n^T \mathbf{x} \end{pmatrix} = d_1 u_1 u_1^T \mathbf{x} + \cdots + d_n u_n u_n^T \mathbf{x}\]

Singular Value Decomposition

<Sepctral Theorem>์€ ๋Œ€์นญ ํ–‰๋ ฌ์— ๋Œ€ํ•ด์„œ ๊ธฐ์ˆ ํ•œ ์ •๋ฆฌ์˜€๋‹ค. ์ด๊ฒƒ์„ ์ผ๋ฐ˜์ ์ธ ํ˜•ํƒœ์˜ ํ–‰๋ ฌ๋กœ ์ผ๋ฐ˜ํ™”ํ•œ ๊ฒƒ์ด ๋ฐ”๋กœ <ํŠน์ด๊ฐ’ ๋ถ„ํ•ด Singular Value Decomposition>์ด๋‹ค. ๐Ÿ˜Ž


Theorem. Singular Value Decomposition

For any $n \times p$ matrix $A$, there exist matrices $U \in \mathbb{R}^{n\times n}$, $D \in \mathbb{R}^{n\times p}$, and $V \in \mathbb{R}^{p\times p}$ s.t.

\[A = UDV^T\]

where

  • $D = \text{diag}(d_1, \dots, d_p)$ with $d_i \ge 0$
    • $d_j$s are called <singular value> of $A$.
  • $U$ is an orthogonal matrix from $AA^T = U(\Sigma\Sigma^T)U^T$
  • $V$ is an orthogonal matrix from $A^T A = V(\Sigma^T \Sigma)V^T$

Low Rank Approximation

SVD๋ฅผ ์ž˜ ์ด์šฉํ•˜๋ฉด, ํ–‰๋ ฌ $A$์— ๋Œ€ํ•œ <Low Rank Approximation> $A_k$๋ฅผ ์œ ๋„ํ•  ์ˆ˜ ์žˆ๋‹ค.

Let $A = UDV^T$ and assume that $n \gg p$, then

\[A = \begin{bmatrix} \vert & & \vert \\ \mathbf{u}_1 & \cdots & \mathbf{u}_n \\ \vert & & \vert \\ \end{bmatrix} \begin{bmatrix} d_1 & & \\ & \ddots \\ & & d_p \\ & O & \end{bmatrix} \begin{bmatrix} - & \mathbf{v}_1^T & - \\ & \vdots & \\ - & \mathbf{v}_p^T & - \\ \end{bmatrix} = d_1 \mathbf{u}_1 \mathbf{v}_1^T + \cdots + d_p \mathbf{u}_p \mathbf{v}_p^T\]

์ด๋•Œ, ํ‘œ๊ธฐ์˜ ํŽธ์˜๋ฅผ ์œ„ํ•ด singular value $d_i$์— ๋Œ€ํ•ด descending order๋กœ ํ‘œ๊ธฐ๋ฅผ ํ•œ๋‹ค.

\[\text{where} \quad d_1 \ge d_2 \cdots \ge d_p\]

์ฃผ๋ชฉํ•  ์ ์€ ์‹์˜ ์šฐ๋ณ€์˜ $\mathbf{u}_i \mathbf{v}_i^T$์€ rank-1 matrix๋ผ๋Š” ์ ์ด๋‹ค. ์ฆ‰, SVD๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด ํ–‰๋ ฌ $A$๋ฅผ rank-1์˜ matrix๋กœ ๋ถ„ํ•ดํ•œ ๊ฒƒ์ด ๋œ๋‹ค.

์ด์ œ ์œ„์˜ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ€์ง€๊ณ  Approximation $A_k$๋ฅผ ์œ ๋„ํ•  ์ˆ˜ ์žˆ๋‹ค.

\[A_k = \begin{bmatrix} \vert & & \vert \\ \mathbf{u}_1 & \cdots & \mathbf{u}_k \\ \vert & & \vert \\ \end{bmatrix} \begin{bmatrix} d_1 & & \\ & \ddots & \\ & & d_k \\ & O & \end{bmatrix} \begin{bmatrix} - & \mathbf{v}_1^T & - \\ & \vdots & \\ - & \mathbf{v}_k^T & - \\ \end{bmatrix} = d_1 \mathbf{u}_1 \mathbf{v}_1^T + \cdots + d_k \mathbf{u}_k \mathbf{v}_k^T\]

์ฆ‰, $A_k$๋Š” $A$๋ฅผ SVD๋กœ ๋ถ„ํ•ดํ•ด ํ‘œํ˜„ํ•œ ๊ฒƒ์—์„œ ์•ž์˜ $k$๊ฐœ์˜ rank-1 matrix๋ฅผ ๋ชจ์€ ๊ฒƒ์ด๋‹ค! ์šฐ๋ฆฌ๊ฐ€ $d_i$๋ฅผ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•ด ํ‘œํ˜„ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋’ค๋กœ ๊ฐˆ์ˆ˜๋ก ์ž‘์€ $d_j$๋ฅผ ์–ป๊ฒŒ ๋˜์–ด ์žˆ๋‹ค. ๊ทธ๋ž˜์„œ $A_k$๋Š” ์•ž์˜ $k$๊ฐœ $d_i$๋งŒ์„ ์„ ํƒํ•ด $A$๋ฅผ ๊ทผ์‚ฌํ•œ ๊ฒƒ์ด๋‹ค!

์ด๋•Œ, <Low Rank Approximation>์˜ error๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด <Frobenius norm>์œผ๋กœ ์ •์˜ํ•œ๋‹ค.

\[\begin{aligned} \| A - A_k \|^2_F &= \text{tr}\left( (A-A_k)^T (A-A_k) \right) \\ &= d_{k+1}^2 + d_{k+2}^2 + \cdots + d_p^2 \end{aligned}\]

๊ทธ๋ž˜์„œ, ๋งŒ์•ฝ ๋’ท๋ถ€๋ถ„์˜ $d_{k+1}, \cdots d_p$์˜ ํฌ๊ธฐ๊ฐ€ ์ž‘๋‹ค๋ฉด, Low Rank Approx๋Š” ์ถฉ๋ถ„ํžˆ ์ •ํ™•ํ•œ ๊ทผ์‚ฌ๋ฅผ ์ˆ˜ํ–‰ํ•จ์„ ๋ณด์žฅํ•  ์ˆ˜ ์žˆ๋‹ค!!

ps. ์ด๋Ÿฐ Low Rank Approx๋Š” ์ƒ๊ฐ๋ณด๋‹ค ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ๋ฒ•์ด๋ผ๊ณ  ํ•œ๋‹ค.

ps. Netflix์˜ ์ถ”์ฒœ ์•Œ๊ณ ๋ฆฌ์ฆ˜ Contest์—์„œ ์ด SVD๋ฅผ ํ™œ์šฉํ•ด Low Rank Approx๋ฅผ ํ•˜๋Š” ์ถ”์ฒœ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ๊ตฌํ˜„ํ•œ ํŒ€์ด ์šฐ์Šน์„ ์ฐจ์ง€ํ–ˆ๋‹ค๊ณ  ํ•œ๋‹ค.


์ง€๊ธˆ๊นŒ์ง€ ํ–‰๋ ฌ์„ ๋ถ„ํ•ดํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ธ <Spectral Decomposition>๊ณผ <Singular Value Decomposition>๋ฅผ ์‚ดํŽด๋ดค๋‹ค. ์ด ๋‘ ๊ฐœ๋…์€ ์ด์–ด์ง€๋Š” ๋‚ด์šฉ์ธ ํ–‰๋ ฌ์˜ <Nonnegative Definite>, <Positive Definite>๋ฅผ ์ •์˜ํ•  ๋•Œ ๋ฐ”ํƒ•์ด ๋œ๋‹ค.

๐Ÿ‘‰ Supp-1: Linear Algebra - 4