Singular Value Decomposition (matrix factorization) Singular Value - - PowerPoint PPT Presentation
Singular Value Decomposition (matrix factorization) Singular Value - - PowerPoint PPT Presentation
Singular Value Decomposition (matrix factorization) Singular Value Decomposition The SVD is a factorization of a matrix into = where is a orthogonal matrix, is a orthogonal
Singular Value Decomposition
The SVD is a factorization of a ๐ร๐ matrix into ๐ฉ = ๐ฝ ๐ป ๐พ๐ผ where ๐ฝ is a ๐ร๐ orthogonal matrix, ๐พ๐ผ is a ๐ร๐ orthogonal matrix and ๐ป is a ๐ร๐ diagonal matrix.
For a square matrix (๐ = ๐):
๐ฉ = โฎ โฆ โฎ ๐& โฆ ๐' โฎ โฆ โฎ ๐& โฑ ๐' โฆ ๐ฐ&
(
โฆ โฎ โฎ โฎ โฆ ๐ฐ'
(
โฆ ๐ฉ = โฎ โฆ โฎ ๐& โฆ ๐' โฎ โฆ โฎ ๐& โฑ ๐' โฎ โฆ โฎ ๐& โฆ ๐' โฎ โฆ โฎ
(
๐& โฅ ๐) โฅ ๐* โฆ
Reduced SVD
๐ฉ = ๐ฝ ๐ป ๐พ๐ผ = โฎ โฆ โฎ โฆ โฎ ๐" โฆ ๐# โฆ ๐$ โฎ โฆ โฎ โฆ โฎ ๐" โฑ ๐# โฎ โฆ ๐ฐ"
%
โฆ โฎ โฎ โฎ โฆ ๐ฐ#
%
โฆ
๐ร๐ ๐ร๐ ๐ร๐
๐ฉ = ๐ฝ๐บ ๐ป๐บ๐พ๐ผ
What happens when ๐ฉ is not a square matrix? 1) ๐ > ๐ We can instead re-write the above as: Where ๐ฝ๐บ is a ๐ร๐ matrix and ๐ป๐บ is a ๐ร๐ matrix
Reduced SVD
๐ฉ = ๐ฝ ๐ป ๐พ๐ผ =
โฎ โฆ โฎ ๐" โฆ ๐# โฎ โฆ โฎ
๐& โฑ ๐. โฑ
โฆ ๐ฐ"
%
โฆ โฎ โฎ โฎ โฆ ๐ฐ$
%
โฆ โฎ โฎ โฎ โฆ ๐ฐ#
%
โฆ
๐ร๐ ๐ร๐ ๐ร๐
๐ฉ = ๐ฝ ๐ป๐บ๐พ๐บ
๐ผ 2) ๐ > ๐ We can instead re-write the above as: where ๐พ๐บ is a ๐ร๐ matrix and ๐ป๐บ is a ๐ร๐ matrix In general:
๐ฉ = ๐ฝ๐บ๐ป๐บ๐พ๐บ
๐ผ
๐ฝ๐บ is a ๐ร๐ matrix ๐ป๐บ is a ๐ ร๐ matrix ๐พ๐บ is a ๐ร๐ matrix ๐ = min(๐, ๐)
Letโs take a look at the product ๐ป๐ผ๐ป, where ๐ป has the singular values of a ๐ฉ, a ๐ร๐ matrix.
๐ป๐ผ๐ป = ๐" โฑ ๐# โฑ ๐" โฑ ๐# โฎ = ๐"$ โฑ ๐#$
๐ร๐ ๐ร๐ ๐ร๐
๐ป๐ผ๐ป = ๐" โฑ ๐% โฎ ๐" โฑ ๐% โฑ = ๐"$ โฑ ๐%$ โฑ โฑ โฑ
๐ร๐ ๐ร๐ ๐ร๐
๐ > ๐ ๐ > ๐
Assume ๐ฉ with the singular value decomposition ๐ฉ = ๐ฝ ๐ป ๐พ๐ผ. Letโs take a look at the eigenpairs corresponding to ๐ฉ๐ผ๐ฉ: ๐ฉ๐ผ๐ฉ = ๐ฝ ๐ป ๐พ๐ผ ๐ผ ๐ฝ ๐ป ๐พ๐ผ ๐พ๐ผ ๐ผ ๐ป
๐ผ๐ฝ๐ผ ๐ฝ ๐ป ๐พ๐ผ = ๐พ๐ป๐ผ๐ฝ๐ผ ๐ฝ ๐ป ๐พ๐ผ = ๐พ ๐ป๐ผ๐ป ๐พ๐ผ
Hence ๐ฉ๐ผ๐ฉ = ๐พ ๐ป๐ ๐พ๐ผ Recall that columns of ๐พ are all linear independent (orthogonal matrix), then from diagonalization (๐ช = ๐๐ฌ๐1๐), we get:
- the columns of ๐พ are the eigenvectors of the matrix ๐ฉ๐ผ๐ฉ
- The diagonal entries of ๐ป๐ are the eigenvalues of ๐ฉ๐ผ๐ฉ
Letโs call ๐ the eigenvalues of ๐ฉ๐ผ๐ฉ, then ๐3) = ๐3
In a similar way, ๐ฉ๐ฉ๐ผ = ๐ฝ ๐ป ๐พ๐ผ ๐ฝ ๐ป ๐พ๐ผ ๐ผ ๐ฝ ๐ป ๐พ๐ผ ๐พ๐ผ ๐ผ ๐ป
๐ผ๐ฝ๐ผ = ๐ฝ ๐ป ๐พ๐ผ๐พ๐ป๐ผ๐ฝ๐ผ = ๐ฝ๐ป ๐ป๐ผ๐ฝ๐ผ
Hence ๐ฉ๐ฉ๐ผ = ๐ฝ ๐ป๐ ๐ฝ๐ผ Recall that columns of ๐ฝ are all linear independent (orthogonal matrices), then from diagonalization (๐ช = ๐๐ฌ๐1๐), we get:
- The columns of ๐ฝ are the eigenvectors of the matrix ๐ฉ๐ฉ๐ผ
How can we compute an SVD of a matrix A ?
- 1. Evaluate the ๐ eigenvectors ๐ฐ3 and eigenvalues ๐3 of ๐ฉ๐ผ๐ฉ
- 2. Make a matrix ๐พ from the normalized vectors ๐ฐ3. The columns are called
โright singular vectorsโ. ๐พ = โฎ โฆ โฎ ๐ฐ& โฆ ๐ฐ' โฎ โฆ โฎ
- 3. Make a diagonal matrix from the square roots of the eigenvalues.
๐ป = ๐& โฑ ๐' ๐3= ๐3 and ๐&โฅ ๐) โฅ ๐* โฆ
- 4. Find ๐ฝ: ๐ฉ = ๐ฝ ๐ป ๐พ๐ผ โน ๐ฝ ๐ป = ๐ฉ ๐พ โน ๐ฝ = ๐ฉ ๐พ ๐ป1๐. The columns
are called the โleft singular vectorsโ.
True or False?
๐ฉ has the singular value decomposition ๐ฉ = ๐ฝ ๐ป ๐พ๐ผ.
- The matrices ๐ฝ and ๐พ are not singular
- The matrix ๐ป can have zero diagonal entries
- ๐ฝ ) = 1
- The SVD exists when the matrix ๐ฉ is singular
- The algorithm to evaluate SVD will fail when taking the square root
- f a negative eigenvalue
Singular values cannot be negative since ๐ฉ๐ผ๐ฉ is a positive semi- definite matrix (for real matrices ๐ฉ)
- A matrix is positive definite if ๐๐ผ๐ช๐ > ๐ for โ๐ โ ๐
- A matrix is positive semi-definite if ๐๐ผ๐ช๐ โฅ ๐ for โ๐ โ ๐
- What do we know about the matrix ๐ฉ๐ผ๐ฉ ?
๐๐ผ ๐ฉ๐ผ๐ฉ ๐ = (๐ฉ๐)๐ผ๐ฉ๐ = ๐ฉ๐ ๐
๐ โฅ 0
- Hence we know that ๐ฉ๐ผ๐ฉ is a positive semi-definite matrix
- A positive semi-definite matrix has non-negative eigenvalues
๐ช๐ = ๐๐ โน ๐๐ผ๐ช๐ = ๐๐ผ ๐ ๐ = ๐ ๐ ๐
๐ โฅ 0 โน ๐ โฅ 0
Singular values are always non-negative
Cost of SVD
The cost of an SVD is proportional to ๐ ๐๐ + ๐๐where the constant of proportionality constant ranging from 4 to 10 (or more) depending on the algorithm.
๐ท456 = ๐ฝ ๐ ๐) + ๐* = ๐ ๐* ๐ท.78.78 = ๐*= ๐ ๐* ๐ท9: = 2๐*/3 = ๐ ๐*
SVD summary:
- The SVD is a factorization of a ๐ร๐ matrix into ๐ฉ = ๐ฝ ๐ป ๐พ๐ผ where ๐ฝ is a ๐ร๐
- rthogonal matrix, ๐พ๐ผ is a ๐ร๐ orthogonal matrix and ๐ป is a ๐ร๐ diagonal matrix.
- In reduced form: ๐ฉ = ๐ฝ๐บ๐ป๐บ๐พ๐บ
๐ผ, where ๐ฝ๐บ is a ๐ร๐ matrix, ๐ป๐บ is a ๐ ร๐ matrix,
and ๐พ๐บ is a ๐ร๐ matrix, and ๐ = min(๐, ๐).
- The columns of ๐พ are the eigenvectors of the matrix ๐ฉ๐ผ๐ฉ, denoted the right singular
vectors.
- The columns of ๐ฝ are the eigenvectors of the matrix ๐ฉ๐ฉ๐ผ, denoted the left singular
vectors.
- The diagonal entries of ๐ป๐ are the eigenvalues of ๐ฉ๐ผ๐ฉ. ๐&=
๐& are called the singular values.
- The singular values are always non-negative (since ๐ฉ๐ผ๐ฉ is a positive semi-definite matrix,
the eigenvalues are always ๐ โฅ 0)
Singular Value Decomposition (applications)
1) Determining the rank of a matrix
๐ฉ = โฎ โฆ โฎ โฆ โฎ ๐" โฆ ๐' โฆ ๐# โฎ โฆ โฎ โฆ โฎ ๐" โฑ ๐' โฎ โฆ ๐ฐ"
(
โฆ โฎ โฎ โฎ โฆ ๐ฐ'
(
โฆ
Suppose ๐ฉ is a ๐ร๐ rectangular matrix where ๐ > ๐: ๐ฉ = =
!"# $
๐!๐!๐ฐ!
%
๐ฉ# = ๐#๐#๐ฐ#
% what is rank ๐ฉ# = ?
In general, rank ๐ฉ& = ๐ A) 1 B) n C) depends on the matrix D) NOTA
๐ฉ = โฎ โฆ โฎ ๐" โฆ ๐' โฎ โฆ โฎ โฆ ๐" ๐ฐ"
(
โฆ โฎ โฎ โฎ โฆ ๐' ๐ฐ'
(
โฆ = ๐"๐"๐ฐ"
( + ๐)๐)๐ฐ) ( + โฏ + ๐'๐'๐ฐ' (
Rank of a matrix
For general rectangular matrix ๐ฉ with dimensions ๐ร๐, the reduced SVD is:
๐ฉ = I
3G& H
๐3๐3๐ฐ3
(
๐ฉ = ๐ฝ๐บ๐ป๐บ๐พ๐บ
๐ผ
๐ร๐ ๐ร๐ ๐ร๐ ๐ ร๐ ๐ = min(๐, ๐)
๐ฏ = ๐# โฑ ๐& โฑ โฆ ๐ฏ = ๐# โฑ ๐& โฑ โฎ
If ๐& โ 0 โ๐, then rank ๐ฉ = ๐ (Full rank matrix) In general, rank ๐ฉ = ๐, where ๐ is the number of non-zero singular values ๐& ๐ < ๐ (Rank deficient)
- The rank of A equals the number of non-zero singular values which is
the same as the number of non-zero diagonal elements in ฮฃ.
- Rounding errors may lead to small but non-zero singular values in a
rank deficient matrix, hence the rank of a matrix determined by the number of non-zero singular values is sometimes called โeffective rankโ.
- The right-singular vectors (columns of ๐พ) corresponding to vanishing
singular values span the null space of A.
- The left-singular vectors (columns of ๐ฝ) corresponding to the non-zero
singular values of A span the range of A.
Rank of a matrix
2) Pseudo-inverse
- Problem: if A is rank-deficient, ๐ป is not be invertible
- How to fix it: Define the Pseudo Inverse
- Pseudo-Inverse of a diagonal matrix:
๐ปN 3 = N
& O& , if ๐3 โ 0
0, if ๐3 = 0
- Pseudo-Inverse of a matrix ๐ฉ:
๐ฉN = ๐พ๐ปN๐ฝ๐ผ
3) Matrix norms
The Euclidean norm of an orthogonal matrix is equal to 1
๐ฝ ) = max
๐ !+" ๐ฝ๐ ) = max ๐ !+"
๐ฝ๐ ๐ผ(๐ฝ๐) = max
๐ !+"
๐๐ผ๐ = max
๐ !+" ๐ ) = 1
The Euclidean norm of a matrix is given by the largest singular value
๐ฉ ) = max
๐ !+" ๐ฉ๐ ) = max ๐ !+" ๐ฝ ๐ป ๐พ๐ผ๐ ) = max ๐ !+" ๐ป ๐พ๐ผ๐ ) =
= max
๐พ๐ผ๐ !+" ๐ป ๐พ๐ผ๐ ) = max ๐ !+" ๐ป ๐ ) = max(๐&)
Where we used the fact that ๐ฝ ) = 1, ๐พ ) = 1 and ๐ป is diagonal ๐ฉ ) = max ๐& = ๐#./
๐'() is the largest singular value
4) Norm for the inverse of a matrix
The Euclidean norm of the inverse of a square-matrix is given by:
Assume here ๐ฉ is full rank, so that ๐ฉ1& exists
๐ฉ0" ) = max
๐ !+" (๐ฝ ๐ป ๐พ๐ผ)0"๐ ) = max ๐ !+" ๐พ ๐ป0๐๐ฝ๐ผ๐ )
Since ๐ฝ ) = 1, ๐พ ) = 1 and ๐ป is diagonal then ๐ฉ0" )=
" 2#$%
๐'!$ is the smallest singular value
5) Norm of the pseudo-inverse matrix
The norm of the pseudo-inverse of a ๐ ร ๐ matrix is: ๐ฉ3 )= "
2&
where ๐4 is the smallest non-zero singular value. This is valid for any matrix, regardless
- f the shape or rank.
Note that for a full rank square matrix, ๐ฉ3 ) is the same as ๐ฉ0" ). Zero matrix: If ๐ฉ is a zero matrix, then ๐ฉ3 is also the zero matrix, and ๐ฉ3 )= 0
The condition number of a matrix is given by ๐๐๐๐) ๐ฉ = ๐ฉ ) ๐ฉ3 ) If the matrix is full rank: ๐ ๐๐๐ ๐ฉ = ๐๐๐ ๐, ๐ ๐๐๐๐) ๐ฉ = ๐#./ ๐#&' where ๐#./ is the largest singular value and ๐#&' is the smallest singular value If the matrix is rank deficient: ๐ ๐๐๐ ๐ฉ < ๐๐๐ ๐, ๐ ๐๐๐๐) ๐ฉ = โ
6) Condition number of a matrix
7) Low-Rank Approximation
Another way to write the SVD (assuming for now ๐ > ๐ for simplicity)
๐ฉ = โฎ โฆ โฎ ๐# โฆ ๐' โฎ โฆ โฎ ๐# โฑ ๐$ โฎ โฆ ๐ฐ#
%
โฆ โฎ โฎ โฎ โฆ ๐ฐ$
%
โฆ = โฎ โฆ โฎ ๐# โฆ ๐$ โฎ โฆ โฎ โฆ ๐# ๐ฐ#
%
โฆ โฎ โฎ โฎ โฆ ๐$ ๐ฐ$
%
โฆ = ๐#๐#๐ฐ#
% + ๐*๐*๐ฐ* % + โฏ + ๐$๐$๐ฐ$ %
The SVD writes the matrix A as a sum of outer products (of left and right singular vectors).
๐" โฅ ๐) โฅ ๐* โฆ โฅ 0
๐ฉH = ๐&๐&๐ฐ&
( + ๐)๐)๐ฐ) ( + โฏ + ๐H๐H๐ฐH (
Note that ๐ ๐๐๐ ๐ฉ = ๐ and ๐ ๐๐๐(๐ฉH) = ๐ and the norm of the difference between the matrix and its approximation is The best rank-๐ approximation for a ๐ร๐ matrix ๐ฉ, (where ๐ โค ๐๐๐(๐, ๐)) is the one that minimizes the following problem: When using the induced 2-norm, the best rank-๐ approximation is given by:
7) Low-Rank Approximation (cont.)
๐ฉ โ ๐ฉ&
* =
๐&+#๐&+#๐ฐ&+#
%
+ ๐&+*๐&+*๐ฐ&+*
%
+ โฏ + ๐$๐$๐ฐ$
% * = ๐&+#
Example: Image compression
๐๐๐ ๐๐๐ ๐๐๐ ๐๐๐๐ ๐๐๐๐ ๐๐๐๐ ๐๐๐ ๐๐๐๐
Example: Image compression
๐๐๐ ๐๐๐๐ Image using rank-50 approximation