Graphic Notes on Linear Algebra and Data Science

Kenji Hiranabe
Kenji HiranabeSoftware developer at Change Vision, Inc.
線形代数計算の視覚化と
⾏列5分解
〜ストラング先⽣から学んだこと〜
平鍋健児(@hiranabe)
Version 1.0
=
1
これは何?
• Gilbert Strang 著
『Linear Algebra for Everyone』
は線形代数を直感理解するのに
とてもいい本です。
• 定理と証明の連鎖ではなく、マトリックス語法と例⽰で直感的な理解と実⽤的な
応⽤法を得ることができます。
• YouTube の MIT Open Courseware、 先⽣の講義プレイリストである 18.06
と 18.065 には、200万⼈の購読者がいます。(ぼくもその⼀⼈です)
• この本のハイライトは、
• AB=C の4つの⾒⽅
• 基本的な4つの部分空間
• 5つのマトリックス分解
• 通常の線形代数の教科書はジョルダン標準形がクライマックスですが、この
本では、SVD です。そして、
• 機械学習を含むデータサイエンスへの⼊⾨につながっています。
• この1と2のコンセプトをグラフィック表現できないか、というアイディアです。
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 2
1
2
この発表
のモチベ
ーション
• ⾏列とベクトルの掛け算には、複数の⾒⽅
があります。
• このノートは、それらを可視化し、教育⽤
コンテンツとする試みです。
• それによって ...
• ⾏列とベクトルの演算を直感的に⾏えるよう
になります。
• その直感を、5つの⾏列分解法、などのコンセ
プトの理解につなげることができます。
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 3
最新版︓
https://github.com/kenjihiranabe/The-Art-of-Linear-Algebra/
http://math.mit.edu/everyone
5つの⾏列分解
𝐴 = 𝐶𝑅
𝐴 = 𝐿𝑈
𝐴 = 𝑄𝑅
𝑆 = 𝑄Λ𝑄!
𝐴 = 𝑈Σ𝑉!
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 4
独⽴列⾏列と⾏簡約⾏列の積
(⾏ランク=列ランクを⽰す)
LU分解=ガウスの消去法
QR分解=Gram-Schmidtの直⾏化
対称⾏列の固有値分解
どんな⻑⽅⾏列にも使える
特異値分解
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 5
Foreword
I am happy to see Kenji Hiranabeʻs pictures of matrix operations in linear algebra ! The
pictures are an excellent way to show the algebra. We can think of matrix
multiplications by (row, column) dot products, but that is not all -- it is ``linear
combinations” and ``rank 1 matrices" that complete the algebra and the art.
I am very grateful to see the books in Japanese translation and the ideas in Kenji's
pictures.
-- Gilbert Strang
Professor of Mathematics at MIT
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 6
• もうすぐ⽇本語訳発売! • ⽇本語訳決定!
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 7
先⽣の講演例:https://www.youtube.com/watch?v=MsIvs_6vC38
⽬次
• ⾏列の⾒⽅ – 4つ
• ベクトルの積 – 2つ
• ⾏列のベクトルの積 – 2つ
• ⾏列と⾏列の積 – 4つ
• 便利な応⽤パターン– 4つ
• ⾏列の有名分解 – 5つ
• 𝐶𝑅, 𝐿𝑈, 𝑄𝑅, 𝑄Λ𝑄!, 𝑈Σ𝑉!
• データサイエンス応⽤で理解する SVD(今⽇だけ)
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 8
= = =
3つの数からなる
2つの列ベクトル
2つの数からなる
3つの⾏ベクトル
6つの数
1 つの⾏列
⾏列の⾒⽅ – 4つ
𝐴 =
𝑎!!𝑎!"
𝑎"!𝑎""
𝑎#!𝑎#"
=
|
𝒂𝟏
|
|
𝒂𝟐
|
=
−𝒂!
∗ −
−𝒂"
∗ −
−𝒂#
∗ −
以降、太字で列ベクトル𝒂𝟏、*を付けて⾏ベクトル𝒂"
∗
、を表現する。
また、右肩にTをつけて転置ベクトル𝒂𝐓や転置⾏列𝑨𝐓を表現する。
𝐴 =
1 4
2 5
3 6
=
1 4
2 5
3 6
=
1 4
2 5
3 6
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 9
= = =
内積(スカラー) Rank1の⾏列
v1 =
1
2
3
𝑥 𝑦 =
𝑥 𝑦
2𝑥 2𝑦
3𝑥 3𝑦
ベクトルの積 – 2つ
1 2 3
𝑥!
𝑥"
𝑥#
=
1
2
3
,
𝑥!
𝑥"
𝑥#
= 𝑥! + 2𝑥" + 3𝑥#
2つの列ベクトル𝒂, 𝒃を𝒂𝒃!
の順に掛けると、⾏
列 (𝐴 = 𝒂𝒃!
) になる。 𝒂, 𝒃どちらも0でなければ、
この⾏列はRankが1になることが分かる。(各
⾏は定数倍であり、各列も定数倍である)
2つの列ベクトルの内積(𝒂 ) 𝒃)は⾏列形
式では、𝒂!
𝒃 と表現され、1つのスカ
ラーになる。
v2
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 10
= = +
⾏列とベクトルの積 – 2つ
𝐴 の⾏ベクトルと列ベクトルの積
(内積)からなる1つの列ベクトル
𝐴 の列ベクトルの線形結合
𝐴𝒙 =
1 2
3 4
5 6
𝑥!
𝑥"
=
(𝑥!+2𝑥")
(3𝑥! + 4𝑥")
(5𝑥! + 6𝑥")
𝐴𝒙 =
1 2
3 4
5 6
𝑥!
𝑥"
= 𝑥!
1
3
5
+ 𝑥"
2
4
6
最初に左を覚えるだろう。しかし、右の⾒⽅ができるようになると、
𝐴𝒙 が𝐴の列ベクトルの線形結合、すなわち、 𝐴の列ベクトル空間 𝐂(𝐴)、
さらに、 𝐴𝒙 = 0 の解がAの零空間 𝐍(𝐴)と読めるようになる。
Mv
1
Mv
2
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 11
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 12
⾏列と⾏列の積 – 4つ
=
1 2
3 4
5 6
𝑥" 𝑦"
𝑥# 𝑦#
=
(𝑥"+2𝑥#) (𝑦"+2𝑦#)
(3𝑥"+4𝑥#) (3𝑦"+4𝑦#)
(5𝑥"+6𝑥#) (5𝑦"+6𝑦#)
1 2
3 4
5 6
𝑥" 𝑦"
𝑥# 𝑦#
= 𝐴 𝒙 𝒚 = 𝐴𝒙 𝐴𝒚
= =
結果の各列 𝐴𝒙, 𝐴𝒚 は、それぞれ𝐴 の列ベクトルの線形結合
結果の各要素は、⾏ベクトルと列ベクトルの内積
MM
1
MM
2
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 13
⾏列と⾏列の積 – 4つ
= +
= =
1 2
3 4
5 6
𝑏"" 𝑏"#
𝑏#" 𝑏##
= 𝒂𝟏 𝒂𝟐
𝒃𝟏
∗
𝒃𝟐
∗ = 𝒂𝟏𝒃𝟏
∗
+ 𝒂𝟐𝒃𝟐
∗
=
1
3
5
𝑏"" 𝑏"# +
2
4
6
𝑏#" 𝑏## =
𝑏"" 𝑏"#
3𝑏"" 3𝑏"#
5𝑏"" 5𝑏"#
+
2𝑏#" 2𝑏##
4𝑏#" 4𝑏##
6𝑏#" 6𝑏##
1 2
3 4
5 6
𝑥" 𝑦"
𝑥# 𝑦#
=
𝒂𝟏
∗
𝒂𝟐
∗
𝒂𝟑
∗
𝑋 =
𝒂𝟏
∗
𝑋
𝒂𝟐
∗
𝑋
𝒂𝟑
∗
𝑋
⾏列の積は、rank 1の⾏列の和に分解される。
結果の各⾏は、⾏ベクトルの線形結合
MM
3
MM
4
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 14
便利な応⽤パターン – 3つ
2 3
=
1 2 3
1 1
=
2
1
+
3
+
2
=
2
1
+
3
+
3
=
2
1
+
3
+
MM
2
Mv
2
右からの操作は、列に作⽤する。
この表現は、右の3つの線形結合を
1つの⾏列表現で表したものだとも
⾔える。
P1
using
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 15
1
2
3
= 1
2
3
1 = +
1 2 3
+
2 = +
1 2 3
+
3 = +
1 2 3
+
MM
3
左からの操作は、⾏に作⽤する。
この表現は、右の3つの線形結合を
1つの⾏列表現で表したものだとも
⾔える。
P2 using
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 16
便利な応⽤パターン – 3つ
= =
𝐴𝐷 = 𝒂𝟏 𝒂𝟐 𝒂𝟑
𝑑!
𝑑"
𝑑#
= 𝑑!𝒂𝟏 𝑑"𝒂𝟐 𝑑"𝒂𝟐 𝐷𝐵 =
𝑑!
𝑑"
𝑑#
𝒃!
∗
𝒃!
∗
𝒃!
∗
=
𝑑!𝒃!
∗
𝑑!𝒃!
∗
𝑑!𝒃!
∗
対⾓⾏列を右から掛けると各列がスカラー倍 対⾓⾏列を左から掛けると各⾏がスカラー倍
これらを⽬に焼き付けると、さらに、、、、
P1ʼ P2ʼ
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 17
便利な応⽤パターン – 3つ
スカラー倍された列ベクトルの線形結合(ベクトル漸化式やベクトル線形微分⽅程式で活⽤)
=
𝑿𝑫𝒄 = 𝒙𝟏 𝒙𝟐 𝒙𝟑
𝑑!
𝑑"
𝑑#
𝑐!
𝑐"
𝑐#
= 𝑐!𝑑!𝒙𝟏 + 𝑐"𝑑"𝒙𝟐+ 𝑐#𝑑#𝒙𝟑
+ +
P3
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 18
便利な応⽤パターン – 3つ
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 19
微分⽅程式、漸化式の例
P3
𝑋 𝑒*+, Λ, 𝒄 𝒙𝟏 𝒙𝟐 𝒙𝟑
= + +
𝑈𝛴𝑉- = 𝒖𝟏 𝒖𝟐 𝒖𝟑
𝜎!
𝜎"
𝜎#
𝒗!
-
𝒗"
-
𝒗#
-
= 𝜎!𝒖!𝒗!
- + 𝜎"𝒖"𝒗"
-+ 𝜎#𝒖#𝒗#
-
rank 1⾏列の和 (SVDや対称⾏列のスペクトル分解で活⽤)
P4
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 20
便利な応⽤パターン – 3つ
𝐴 = 𝐶𝑅
𝐴 = 𝐿𝑈
𝐴 = 𝑄𝑅
𝑆 = 𝑄Λ𝑄!
𝐴 = 𝑈Σ𝑉!
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 21
独⽴列⾏列と⾏簡約⾏列の積
(⾏ランク=列ランクを⽰す)
LU分解=ガウスの消去法
QR分解=Gram-Schmidtの直⾏化
対称⾏列の固有値分解
どんな⻑⽅⾏列にも使える
特異値分解
⾏列の有名分解 – 5つ
𝐴 = 𝐶𝑅
𝐴の列ベクトルを左から順に⾒て、独⽴なもののみ選び出していく。1,2列⽬は⽣き残り、3列⽬は1列⽬+2列
⽬なので捨てる。残った2つの列ベクトルCを使って𝐴 を復元すると、𝑅には階段⾏列が現れる。
これを、よく⾒て、⼆つの表現で表すと…
⻑⽅⾏列𝐴の⾏ランクと、 𝐴の列ランクが等しいことを最も直感的に⽰す分解。
Cは𝐴の線形独⽴な列ベクトル。 𝑅は⾏簡約階段⾏列(row reduced echelon form)となる。
1 2 3
2 3 5
=
1 2
2 3
1 0 1
0 1 1
|
𝒂𝟏
|
|
𝒂𝟐
|
|
𝒂𝟑
|
=
|
𝒄𝟏
|
|
𝒄𝟐
|
1 0 1
0 1 1
𝒂𝟏 = 𝒄𝟏, 𝒂𝟐= 𝒄𝟐, 𝒂𝟑 = 𝒄𝟏 + 𝒄𝟐
−𝒂"
∗
−
−𝒂#
∗
−
=
1 2
2 3
−𝒓"
∗
−
−𝒓#
∗
−
𝒂"
∗
= 𝒓"
∗
+ 2𝒓#
∗
, 𝒂#
∗
= 2𝒓"
∗
+ 3𝒓#
∗
= 2
1 = 1 + 2 1 + 2 1 + 2
すべての列ベクトルはc1,c2の線形結合。すなわち、列ランク=dim C(𝐴)=2。
= +
1
2
1 2
1 2
+
=
すべての⾏ベクトルはr1,r2の線形結合。すなわち、⾏ランク=dim C(𝐴!
)=2。
𝐴 = 𝐶𝑅
P1
P2
using
using
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 22
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 23
= 2
1 = 1 + 2 1 + 2 1 + 2
1 2 3
2 3 5
= +
1
2
1 2
1 2
+
=
𝐴 =
|
𝒍𝟏
|
−𝒖!
∗
− +
0 0 0
0
0
𝐴"
=
|
𝒍𝟏
|
−𝒖!
∗
− +
|
𝒍𝟐
|
−𝒖"
∗
− +
0 0 0
0 0 0
0 0 𝐴#
= 𝐿𝑈
𝐴 = 𝐿𝑈
𝐴の⾏1ベクトルと列1ベクトルでできる rank 1⾏列を取り出し、サイズが1つ減った⾏列を𝐴# とする。
この操作を再帰的に繰り返して、rank 1 の和に分解する。
= + +
𝐿𝑈 を逆向きに計算して𝐴 に戻すのは容易。
MM
4
ガウスの消去法は、⾏基本変形をAの左から掛けていくが、その逆⾏列が 𝐿である。
using
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 24
=
= + +
𝐿 𝑈
𝐴
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 25
=
= + +
𝐿 𝑈
𝐴
1 2 4
2
1
5
5
1
3
=
=
𝐴 = 𝑄𝑅
𝐴の各列ベクトルを、Gram-Schmidtの直⾏化によって𝑄 の列ベクトルに直⾏化する。
その際の係数を逆にすることで、𝑅に上三⾓⾏列が作られる。
Gram-Schmidt の直⾏化。
2 3
1
|
𝒂𝟏
|
|
𝒂𝟐
|
|
𝒂𝟑
|
=
|
𝒒𝟏
|
|
𝒒𝟐
|
|
𝒒𝟑
|
𝑟"" 𝑟"# 𝑟"(
𝑟## 𝑟#(
𝑟((
3
1
+
1 2
+
1 2
+
𝒂𝟏 = 𝑟""𝒒𝟏
𝒂𝟐 = 𝑟"#𝒒𝟏 + 𝑟##𝒒𝟐
𝒂𝟐 = 𝑟"(𝒒𝟏 + 𝑟#(𝒒𝟐 + 𝑟((𝒒𝟑
𝐴 = 𝑄𝑅
P1
using
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 26
𝑄 𝑅
𝐴 𝒂𝟏 𝒂𝟐 𝒂𝟑
𝑆 = 𝑄𝛬𝑄-=
|
𝒒𝟏
|
|
𝒒𝟐
|
|
𝒒𝟑
|
𝜆!
𝜆"
𝜆#
−𝒒!
-
−
−𝒒"
- −
−𝒒#
-
−
=𝜆!
|
𝒒𝟏
|
−𝒒!
- − + 𝜆"
|
𝒒𝟐
|
−𝒒"
- − + 𝜆#
|
𝒒𝟑
|
−𝒒#
- −
𝑆 = 𝑄𝛬𝑄*
対称⾏列𝑆は、直⾏⾏列𝑄によって固有値の対⾓⾏列𝛬に対⾓化される。
さらに、これを rank 1 の射影⾏列の和に分解できる。(スペクトル分解)
= 𝜆!𝑃! + 𝜆"𝑃" + 𝜆#𝑃#
対称⾏列𝑆の固有値分解。固有値はすべて実数であり、固有ベクトルは必ず互いに直⾏したものが取れる。
2 3
1
= + +
= 1
2
3
1
1
2
2
3
3 P4
using
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 27
𝑄 𝛬
𝑆 𝑄. 𝜆!𝒒𝟏𝒒!
.
𝜆"𝒒𝟐𝒒"
.
𝜆#𝒒𝟑𝒒#
.
𝑆 = 𝑆-
𝑄-𝑄 = 𝑃! +𝑃" + 𝑃# = 𝐼
𝑃!𝑃" = 𝑃"𝑃# = 𝑃#𝑃! = 𝑂
𝐴 = 𝑈Σ𝑉+
𝐴の⾏空間ℝ)
の正規直交基底として𝑉、列空間 ℝ*
の正規直交規定として𝑈をそれぞれうまく取ると、対
⾓化される。これを特異値分解という。さらに、これを rank 1 ⾏列の和に分解できる。
𝐴が⼀般の⻑⽅⾏列の場合でも、特異値分解は必ず可能。
= +
=
1
1
2
2
2 3
1
1
2
P4
using
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 28
𝑈 Σ
𝐴 𝑉- 𝜎! 𝒖𝟏𝒗!
-
𝜎" 𝒖𝟐𝒗"
-
𝑈𝑈- = 𝐼/
𝑉𝑉- = 𝐼,
𝐴 = 𝑈Σ𝑉-=
|
𝒖𝟏
|
|
𝒖𝟐
|
|
𝒖𝟑
|
𝜎!
𝜎"
−𝒗!
- −
−𝒗"
- −
=𝜎!
|
𝒖𝟏
|
− 𝒗!
-
− + 𝜎"
|
𝒖𝟐
|
− 𝒗"
-
−
= 𝜎!𝒖𝟏𝒗!
- + 𝜎"𝒖𝟐𝒗"
-
SVDの応⽤からの理解︓ eigenface
Washington ⼤学の Steve Brunton 先⽣の YouTube チャネル
にて、120回以上の動画で詳しくこの本の中について解説されて
いる。その中の、eigenface の回をご紹介。
Databookuw.com
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang
Eigenfaces – Yale B Dataset
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 30
256値×32K 画素×64枚× 36⼈、から、特異値ベクトルを抽出
⾏列の2つの意味(1.写像)
𝐴 ∈ 𝑀 𝑚×𝑛, ℝ m⾏n列の実数要素の⾏列
1. ℝ!→ ℝ" の線形写像と⾒る
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 31
ℝ" ℝ#
→
𝑥
𝐴
𝐴𝑥
𝑥∈ℝ" n次元列ベクトル
𝐴𝑥∈ℝ# m次元列ベクトル
𝐶 A = 𝐴𝑥 𝑥∈ℝ"
} Aの列空間⊂ ℝ#
𝑁 A = 𝑥 𝑥∈ℝ", 𝐴𝑥 = 0} Aの零空間⊂ ℝ"
= +
𝐴 の列ベクトルの線形結合
𝑨𝒙 =
1 0
2 1
3 1
𝑥!
𝑥"
= 𝑥!
1
2
3
+ 𝑥"
0
1
1
Mv
2
rank 𝐴 = dim 𝐶(𝐴)
m x n の時、 ℝ%
→ ℝ&
nが⼊⼒m
が出⼒であることに注意。
⾏列の2つの意味(2.データ)
2. ℝ" のデータセットが𝑛列と⾒る。
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 32
𝑎$, 𝑎%, … , 𝑎" ∈ ℝ# m次元列ベクトルのデータ
𝑢$, 𝑢%, … , 𝑢# ∈ ℝ# m次元列ベクトルの底
|
𝒂𝟏
|
|
𝒂𝟐
|
|
𝒂𝟑
|
=
|
𝒆𝟏
|
|
𝒆𝟐
|
|
𝒆𝟑
|
1 0 1
2
3
1
1
3
4
2 3
=
1
2 3
1
1
=
2
1
+
3
+
2
=
2
1
+
3
+
3
=
2
1
+
3
+
P1
𝒂𝟏 = 𝒖𝟏, 𝒂𝟐 = 𝒖𝟐, 𝒂𝟐 = 𝒖𝟏 + 𝒖𝟐
|
𝒂𝟏
|
|
𝒂𝟐
|
|
𝒂𝟑
|
=
|
𝒖𝟏
|
|
𝒖𝟐
|
|
𝒖𝟑
|
1 0 1
0
0
1
0
1
0
新しい基底(u1,u2,u3)の線形結合として各列を表す
通常の基底(e1,e2,e3)の線形結合として各列を表す 基底
この基底での「座標」
もしくは「成分」が
縦に並ぶ。
各データベクトル
𝑨 =
1 0 1
2
3
1
1
3
4
フーリエ変換等でもデータ圧縮可能
だが、SVDではデータ駆動で(デー
タ全体を⾒てから)有効な底を決め
る。
固有値/固有ベクトル(復習)
𝐴 ∈ 𝑀 𝑛×𝑛, ℝ n⾏n列の実数要素の正⽅⾏列
1. ℝ!→ ℝ! の線形写像と⾒る
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 33
ℝ" ℝ"
→
𝑥
𝐴
𝐴𝑥
⽅向を変えないベクトルがある。
それらを基底とする(座標は⼲渉しないで定数倍になる)。
𝐴𝒑$ = 𝜆$𝒑$
𝐴𝒑% = 𝜆%𝒑%
𝐴𝒑& = 𝜆&𝒑&
𝐴𝑥 = 𝜆𝑥
𝐴𝑃 = 𝑃𝛬, 𝐴 = 𝑃𝛬𝑃2!
𝑨
|
𝒑𝟏
|
|
𝒑𝟐
|
|
𝒑𝟑
|
=
|
𝒑𝟏
|
|
𝒑𝟐
|
|
𝒑𝟑
|
𝜆!
𝜆"
𝜆#
1
= 1
1
2
= 2
2
3
= 3
3
1
2
3
2 3
1
2 3
1
=
※必ずn本取れるとは限らない。
対称⾏列なら正規直交なPが必ず取れ、λは実数。
特異値/特異ベクトル
𝐴 ∈ 𝑀 𝑚×𝑛, ℝ m⾏n列の実数要素の⻑⽅⾏列
1. ℝ!→ ℝ" の線形写像と⾒る
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 34
ℝ" ℝ#
→
𝑥
𝐴
𝐴𝑥
別の正規直⾏ベクトルを基底とする。
座標は⼲渉しないで定数倍(⾮負の実数)になる。
𝐴𝒗$ = 𝜎$𝒖$
𝐴𝒗% = 𝜎%𝒖%
𝐴𝒗& = 𝜎&𝒖&
𝐴𝑉 = 𝑈Σ
𝐴 = 𝑈Σ𝑉!
1
= 1
1
2
= 2
2
3
= 3
3
1
2
3
2 3
1
2 3
1
=
※必ず分解でき、⼀意になる。
1
2
3
2 3
1
= 1
2
3
特異値/特異ベクトル
1. 𝑛個の ℝ" のデータセットと⾒る。
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 35
2 3
1
2 3
1 1
=
2
1
+
3
+
2
=
2
1
+
3
+
3
=
2
1
+
3
+
新基底
各データベクトル
(各⾃の顔データ)
2 3
1
=
=
新基底
(eigen face)
𝐴 = 𝑈Σ𝑉"
𝐴 =
|
𝒖𝟏
|
|
𝒖𝟐
|
|
𝒖𝟑
|
𝜎&
𝜎'
𝜎(
−𝒗&
"
−
−𝒗'
" −
−𝒗(
"
−
𝐴 𝑉'
𝑈 Σ (Σ𝑉')
𝑈
=
=
A	の各列(face)は、新基底(eigenface)の線形結合。
A	全体の中での信号の強さが特異値。
データごとの
Mixture(Vの⾏)
信号の強さ
(特異値)
新基底での座標
(各⾃の顔の成分)
新基底での座標
(各⾃の顔の成分)
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 36
⼿で分解するには、 𝐴'𝐴(どんな𝐴でも対称⾏列となる)を使う。
𝐴 = 𝑈Σ𝑉"
𝐴"𝐴 = (𝑈Σ𝑉")"𝑈Σ𝑉" = 𝑉Σ'𝑉"
となり、 𝐴"𝐴(対称⾏列)の対⾓化(固有値)を求めるのと同じ問題に帰着。
1. 𝐴"𝐴 を計算。
2. それを対⾓化、すなわち固有値𝜎'と固有ベクトル 𝒗 をn個求める。
3. それらが、 Σ', 𝑉 となる。
4. Σと𝑉が求まったら、 𝐴𝒗 = 𝜎𝒖 より、𝒗 に対応する 𝒖求めて、 𝑼とする。
これは⼿計算⽤で、通常、コンピュータの数値演算は全く違う
⽅法(シフト付きQRなど) をとる。
特異値/特異ベクトル
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 37
直感で SVD 出来ますか︖
1. 𝐴 = 3
2. 𝐴 =
1
2
3. 𝐴 =
1 3
2 6
直感 or 計算で SVD 出来ますか︖
ポイント
𝐴 = 𝑈Σ𝑉!
単位直⾏⾏列
(⻑さ・⾓度を変えない)
(回転と捉えて良い)
対⾓⾏列
(向きを変えない)
(スケールと捉えて良い)
𝑈
𝑉
𝑈の次元は?
𝑉の次元は?
ℝ" ℝ#
𝐴
⾏空間 列空間
→
= 1 3 1
=
1
5
1
2
5 1
=
1
5
1 −2
2 1
5
0
1
特異値/特異ベクトル
Eigenfaces – Yale B Dataset
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 38
256値×32K 画素×64枚× 36⼈、から、特異値ベクトルを抽出
最初の 64 eigenfaces(ちょっと怖い…)
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 39
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 40
顔データを元よりも少数
次元の基底によって復元
する。
基底は、U を特異値の⼩
さい⽅を削除ししまった
近似。
このU平⾯に新しい顔を
射影し、その座標(少数)
をαという。このαを使っ
て、新しい顔を表現する。
(データ圧縮)
顔を次元を順次増
やして復元。
効率は良くないが、
⽝も表現できるよ。
(だいぶ怖い)
参照⽂献と
謝辞
• Linear Algebra for Everyone
(⽇本語 来年)
http://math.mit.edu/everyone/
• MIT OpenCourseWare 18.06
http://web.mit.edu/18.06/www/vi
deos.shtml
• A 2020 Vision of Linear Algebra
https://ocw.mit.edu/resources/res
-18-010-a-2020-vision-of-linear-
algebra-spring-2020/
• マトリックスワールド
https://anagileway.com/2020/09/
29/matrix-world-in-linear-algebra-
for-everyone/
• 4つの部分空間 Tシャツ
https://anagileway.com/2020/06/
04/prof-gilbert-strang-linear-
algebra/
This work is inspired by Prof. Strangʼs
books and lecture videos. I deeply
appreciate his work, passion and
personality.
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang
41
By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 42
Tシャツ作った!
Thank you for
reading!
Any comments or feedbacks are welcome to:
Kenji Hiranabe (hiranabe@gmail.com)
=
43
1 of 43

Recommended

金融時系列のための深層t過程回帰モデル by
金融時系列のための深層t過程回帰モデル金融時系列のための深層t過程回帰モデル
金融時系列のための深層t過程回帰モデルKei Nakagawa
2K views20 slides
スペクトラルグラフ理論入門 by
スペクトラルグラフ理論入門スペクトラルグラフ理論入門
スペクトラルグラフ理論入門irrrrr
38.4K views44 slides
最適輸送入門 by
最適輸送入門最適輸送入門
最適輸送入門joisino
11.6K views88 slides
【解説】 一般逆行列 by
【解説】 一般逆行列【解説】 一般逆行列
【解説】 一般逆行列Kenjiro Sugimoto
80.6K views28 slides
クラシックな機械学習入門:付録:よく使う線形代数の公式 by
クラシックな機械学習入門:付録:よく使う線形代数の公式クラシックな機械学習入門:付録:よく使う線形代数の公式
クラシックな機械学習入門:付録:よく使う線形代数の公式Hiroshi Nakagawa
17.5K views9 slides

More Related Content

What's hot

深層生成モデルと世界モデル by
深層生成モデルと世界モデル深層生成モデルと世界モデル
深層生成モデルと世界モデルMasahiro Suzuki
16.6K views57 slides
変分推論法(変分ベイズ法)(PRML第10章) by
変分推論法(変分ベイズ法)(PRML第10章)変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)Takao Yamanaka
30.5K views34 slides
深層学習の数理 by
深層学習の数理深層学習の数理
深層学習の数理Taiji Suzuki
79.7K views182 slides
[DL輪読会]Deep Learning 第15章 表現学習 by
[DL輪読会]Deep Learning 第15章 表現学習[DL輪読会]Deep Learning 第15章 表現学習
[DL輪読会]Deep Learning 第15章 表現学習Deep Learning JP
9.8K views33 slides
混合モデルとEMアルゴリズム(PRML第9章) by
混合モデルとEMアルゴリズム(PRML第9章)混合モデルとEMアルゴリズム(PRML第9章)
混合モデルとEMアルゴリズム(PRML第9章)Takao Yamanaka
70.9K views46 slides
グラフィカルモデル入門 by
グラフィカルモデル入門グラフィカルモデル入門
グラフィカルモデル入門Kawamoto_Kazuhiko
117.9K views67 slides

What's hot(20)

深層生成モデルと世界モデル by Masahiro Suzuki
深層生成モデルと世界モデル深層生成モデルと世界モデル
深層生成モデルと世界モデル
Masahiro Suzuki16.6K views
変分推論法(変分ベイズ法)(PRML第10章) by Takao Yamanaka
変分推論法(変分ベイズ法)(PRML第10章)変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)
Takao Yamanaka30.5K views
深層学習の数理 by Taiji Suzuki
深層学習の数理深層学習の数理
深層学習の数理
Taiji Suzuki79.7K views
[DL輪読会]Deep Learning 第15章 表現学習 by Deep Learning JP
[DL輪読会]Deep Learning 第15章 表現学習[DL輪読会]Deep Learning 第15章 表現学習
[DL輪読会]Deep Learning 第15章 表現学習
Deep Learning JP9.8K views
混合モデルとEMアルゴリズム(PRML第9章) by Takao Yamanaka
混合モデルとEMアルゴリズム(PRML第9章)混合モデルとEMアルゴリズム(PRML第9章)
混合モデルとEMアルゴリズム(PRML第9章)
Takao Yamanaka70.9K views
グラフィカルモデル入門 by Kawamoto_Kazuhiko
グラフィカルモデル入門グラフィカルモデル入門
グラフィカルモデル入門
Kawamoto_Kazuhiko117.9K views
深層生成モデルを用いたマルチモーダル学習 by Masahiro Suzuki
深層生成モデルを用いたマルチモーダル学習深層生成モデルを用いたマルチモーダル学習
深層生成モデルを用いたマルチモーダル学習
Masahiro Suzuki9.5K views
因果探索: 観察データから 因果仮説を探索する by Shiga University, RIKEN
因果探索: 観察データから因果仮説を探索する因果探索: 観察データから因果仮説を探索する
因果探索: 観察データから 因果仮説を探索する
PRMLの線形回帰モデル(線形基底関数モデル) by Yasunori Ozaki
PRMLの線形回帰モデル(線形基底関数モデル)PRMLの線形回帰モデル(線形基底関数モデル)
PRMLの線形回帰モデル(線形基底関数モデル)
Yasunori Ozaki45.5K views
強化学習と逆強化学習を組み合わせた模倣学習 by Eiji Uchibe
強化学習と逆強化学習を組み合わせた模倣学習強化学習と逆強化学習を組み合わせた模倣学習
強化学習と逆強化学習を組み合わせた模倣学習
Eiji Uchibe25.3K views
PRML 6.1章 カーネル法と双対表現 by hagino 3000
PRML 6.1章 カーネル法と双対表現PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現
hagino 30005K views
Active Learning 入門 by Shuyo Nakatani
Active Learning 入門Active Learning 入門
Active Learning 入門
Shuyo Nakatani51.8K views
グラフニューラルネットワーク入門 by ryosuke-kojima
グラフニューラルネットワーク入門グラフニューラルネットワーク入門
グラフニューラルネットワーク入門
ryosuke-kojima51.5K views
Fisher Vectorによる画像認識 by Takao Yamanaka
Fisher Vectorによる画像認識Fisher Vectorによる画像認識
Fisher Vectorによる画像認識
Takao Yamanaka22.5K views
猫でも分かりたい線形回帰の自由度 by YukinoriKambe
猫でも分かりたい線形回帰の自由度猫でも分かりたい線形回帰の自由度
猫でも分かりたい線形回帰の自由度
YukinoriKambe3.7K views
渡辺澄夫著「ベイズ統計の理論と方法」5.1 マルコフ連鎖モンテカルロ法 by Kenichi Hironaka
渡辺澄夫著「ベイズ統計の理論と方法」5.1 マルコフ連鎖モンテカルロ法渡辺澄夫著「ベイズ統計の理論と方法」5.1 マルコフ連鎖モンテカルロ法
渡辺澄夫著「ベイズ統計の理論と方法」5.1 マルコフ連鎖モンテカルロ法
Kenichi Hironaka1.1K views
モンテカルロサンプリング by Kosei ABE
モンテカルロサンプリングモンテカルロサンプリング
モンテカルロサンプリング
Kosei ABE12.8K views
有向グラフに対する 非線形ラプラシアンと ネットワーク解析 by Yuichi Yoshida
有向グラフに対する 非線形ラプラシアンと ネットワーク解析有向グラフに対する 非線形ラプラシアンと ネットワーク解析
有向グラフに対する 非線形ラプラシアンと ネットワーク解析
Yuichi Yoshida7.3K views

Similar to Graphic Notes on Linear Algebra and Data Science

Graphic Notes on Introduction to Linear Algebra by
Graphic Notes on Introduction to Linear AlgebraGraphic Notes on Introduction to Linear Algebra
Graphic Notes on Introduction to Linear AlgebraKenji Hiranabe
1.9K views19 slides
行列(人間科学のための基礎数学) by
行列(人間科学のための基礎数学)行列(人間科学のための基礎数学)
行列(人間科学のための基礎数学)Masahiro Okano
962 views50 slides
MT102 Лекц 16 by
MT102 Лекц 16MT102 Лекц 16
MT102 Лекц 16ssuser184df1
120 views34 slides
Matrix algebra by
Matrix algebraMatrix algebra
Matrix algebraFarzad Javidanrad
17.9K views39 slides
Examples of Functions and Their Graphs.pptx by
Examples of Functions and Their Graphs.pptxExamples of Functions and Their Graphs.pptx
Examples of Functions and Their Graphs.pptxJimmyAbalos1
4 views22 slides
Parallel Line Properties by
Parallel Line PropertiesParallel Line Properties
Parallel Line PropertiesFidelfo Moral
17.5K views18 slides

Similar to Graphic Notes on Linear Algebra and Data Science(20)

Graphic Notes on Introduction to Linear Algebra by Kenji Hiranabe
Graphic Notes on Introduction to Linear AlgebraGraphic Notes on Introduction to Linear Algebra
Graphic Notes on Introduction to Linear Algebra
Kenji Hiranabe1.9K views
行列(人間科学のための基礎数学) by Masahiro Okano
行列(人間科学のための基礎数学)行列(人間科学のための基礎数学)
行列(人間科学のための基礎数学)
Masahiro Okano962 views
Examples of Functions and Their Graphs.pptx by JimmyAbalos1
Examples of Functions and Their Graphs.pptxExamples of Functions and Their Graphs.pptx
Examples of Functions and Their Graphs.pptx
JimmyAbalos14 views
Parallel Line Properties by Fidelfo Moral
Parallel Line PropertiesParallel Line Properties
Parallel Line Properties
Fidelfo Moral17.5K views
Rabbit challenge 1_math by TOMMYLINK1
Rabbit challenge 1_mathRabbit challenge 1_math
Rabbit challenge 1_math
TOMMYLINK149 views
Get the facts, jack! by sgibson1626
Get the facts, jack!Get the facts, jack!
Get the facts, jack!
sgibson16263.7K views
February 17, 2015 by khyps13
February 17, 2015February 17, 2015
February 17, 2015
khyps13466 views
Lecture_9_LA_Review.pptx by Sunny432360
Lecture_9_LA_Review.pptxLecture_9_LA_Review.pptx
Lecture_9_LA_Review.pptx
Sunny4323608 views
Algebra equations & inequalities by Ourutopy
Algebra equations & inequalitiesAlgebra equations & inequalities
Algebra equations & inequalities
Ourutopy3.5K views
CLASS 9 LINEAR EQUATIONS IN TWO VARIABLES PPT by 05092000
CLASS 9 LINEAR EQUATIONS IN TWO VARIABLES PPTCLASS 9 LINEAR EQUATIONS IN TWO VARIABLES PPT
CLASS 9 LINEAR EQUATIONS IN TWO VARIABLES PPT
0509200030.5K views

More from Kenji Hiranabe

effective ba for online communication by
effective ba for online communication effective ba for online communication
effective ba for online communication Kenji Hiranabe
84 views43 slides
線形代数の視覚的理解 V1.1-Gストラング勉強会 by
線形代数の視覚的理解 V1.1-Gストラング勉強会線形代数の視覚的理解 V1.1-Gストラング勉強会
線形代数の視覚的理解 V1.1-Gストラング勉強会Kenji Hiranabe
474 views16 slides
Math in Machine Learning / PCA and SVD with Applications by
Math in Machine Learning / PCA and SVD with ApplicationsMath in Machine Learning / PCA and SVD with Applications
Math in Machine Learning / PCA and SVD with ApplicationsKenji Hiranabe
842 views35 slides
Scrum-Fest-Sapporo-2021-Keynote-Our-Journey by
Scrum-Fest-Sapporo-2021-Keynote-Our-JourneyScrum-Fest-Sapporo-2021-Keynote-Our-Journey
Scrum-Fest-Sapporo-2021-Keynote-Our-JourneyKenji Hiranabe
889 views91 slides
Appreciating Your Way to XP by
Appreciating Your Way to XPAppreciating Your Way to XP
Appreciating Your Way to XPKenji Hiranabe
1.3K views50 slides
Digital Business and Agile by
Digital Business and AgileDigital Business and Agile
Digital Business and AgileKenji Hiranabe
510 views117 slides

More from Kenji Hiranabe(20)

effective ba for online communication by Kenji Hiranabe
effective ba for online communication effective ba for online communication
effective ba for online communication
Kenji Hiranabe84 views
線形代数の視覚的理解 V1.1-Gストラング勉強会 by Kenji Hiranabe
線形代数の視覚的理解 V1.1-Gストラング勉強会線形代数の視覚的理解 V1.1-Gストラング勉強会
線形代数の視覚的理解 V1.1-Gストラング勉強会
Kenji Hiranabe474 views
Math in Machine Learning / PCA and SVD with Applications by Kenji Hiranabe
Math in Machine Learning / PCA and SVD with ApplicationsMath in Machine Learning / PCA and SVD with Applications
Math in Machine Learning / PCA and SVD with Applications
Kenji Hiranabe842 views
Scrum-Fest-Sapporo-2021-Keynote-Our-Journey by Kenji Hiranabe
Scrum-Fest-Sapporo-2021-Keynote-Our-JourneyScrum-Fest-Sapporo-2021-Keynote-Our-Journey
Scrum-Fest-Sapporo-2021-Keynote-Our-Journey
Kenji Hiranabe889 views
Appreciating Your Way to XP by Kenji Hiranabe
Appreciating Your Way to XPAppreciating Your Way to XP
Appreciating Your Way to XP
Kenji Hiranabe1.3K views
線形代数の視覚的理解のためのノート by Kenji Hiranabe
線形代数の視覚的理解のためのノート線形代数の視覚的理解のためのノート
線形代数の視覚的理解のためのノート
Kenji Hiranabe1.1K views
with コロナ時代のアジャイルとコミュニケーション by Kenji Hiranabe
with コロナ時代のアジャイルとコミュニケーションwith コロナ時代のアジャイルとコミュニケーション
with コロナ時代のアジャイルとコミュニケーション
Kenji Hiranabe9.8K views
Agile Ba with Covid at Redmine Japan 2020 by Kenji Hiranabe
Agile Ba with Covid at Redmine Japan 2020Agile Ba with Covid at Redmine Japan 2020
Agile Ba with Covid at Redmine Japan 2020
Kenji Hiranabe2.8K views
ESM Agile Studio DX and COVID by Kenji Hiranabe
ESM Agile Studio DX and COVIDESM Agile Studio DX and COVID
ESM Agile Studio DX and COVID
Kenji Hiranabe336 views
Essence position talk by hiranabe by Kenji Hiranabe
Essence position talk by hiranabeEssence position talk by hiranabe
Essence position talk by hiranabe
Kenji Hiranabe1.3K views
Agile Scrum at Knowledge Forum 2020 by Kenji Hiranabe
Agile Scrum at Knowledge Forum 2020Agile Scrum at Knowledge Forum 2020
Agile Scrum at Knowledge Forum 2020
Kenji Hiranabe656 views
Ba and digital here now ness by Kenji Hiranabe
Ba and digital here now nessBa and digital here now ness
Ba and digital here now ness
Kenji Hiranabe3.1K views
Modeling in the Agile Age and casual astah models by Kenji Hiranabe
Modeling in the Agile Age and casual astah modelsModeling in the Agile Age and casual astah models
Modeling in the Agile Age and casual astah models
Kenji Hiranabe1.3K views
Modeling in the Agile Age by Kenji Hiranabe
Modeling in the Agile Age Modeling in the Agile Age
Modeling in the Agile Age
Kenji Hiranabe11K views
Agile in automotive industry by Kenji Hiranabe
Agile in automotive industryAgile in automotive industry
Agile in automotive industry
Kenji Hiranabe1.2K views
Introduction to Agile - how business and engineer team up by Kenji Hiranabe
Introduction to Agile - how business and engineer team upIntroduction to Agile - how business and engineer team up
Introduction to Agile - how business and engineer team up
Kenji Hiranabe1.2K views
5-principles-for-project-facilitation by Kenji Hiranabe
5-principles-for-project-facilitation5-principles-for-project-facilitation
5-principles-for-project-facilitation
Kenji Hiranabe8.1K views
Nonaka Scrum - The New New Product Development Game, SECI model, The US Marin... by Kenji Hiranabe
Nonaka Scrum - The New New Product Development Game, SECI model, The US Marin...Nonaka Scrum - The New New Product Development Game, SECI model, The US Marin...
Nonaka Scrum - The New New Product Development Game, SECI model, The US Marin...
Kenji Hiranabe3.9K views

Recently uploaded

Geometrical qualities of the generalised Schwarzschild spacetimes by
Geometrical qualities of the generalised Schwarzschild spacetimesGeometrical qualities of the generalised Schwarzschild spacetimes
Geometrical qualities of the generalised Schwarzschild spacetimesOrchidea Maria Lecian
8 views42 slides
Paper Chromatography or Paper partition chromatography by
Paper Chromatography or Paper partition chromatographyPaper Chromatography or Paper partition chromatography
Paper Chromatography or Paper partition chromatographyPoonam Aher Patil
7 views34 slides
Cyanobacteria as a Biofertilizer (BY- Ayushi).pptx by
Cyanobacteria as a Biofertilizer (BY- Ayushi).pptxCyanobacteria as a Biofertilizer (BY- Ayushi).pptx
Cyanobacteria as a Biofertilizer (BY- Ayushi).pptxAyushiKardam
5 views13 slides
BLOTTING TECHNIQUES SPECIAL by
BLOTTING TECHNIQUES SPECIALBLOTTING TECHNIQUES SPECIAL
BLOTTING TECHNIQUES SPECIALMuhammadImranMirza2
14 views56 slides
AI for automated materials discovery via learning to represent, predict, gene... by
AI for automated materials discovery via learning to represent, predict, gene...AI for automated materials discovery via learning to represent, predict, gene...
AI for automated materials discovery via learning to represent, predict, gene...Deakin University
6 views44 slides
DNA manipulation Enzymes 2.pdf by
DNA manipulation Enzymes 2.pdfDNA manipulation Enzymes 2.pdf
DNA manipulation Enzymes 2.pdfNetHelix
6 views42 slides

Recently uploaded(20)

Geometrical qualities of the generalised Schwarzschild spacetimes by Orchidea Maria Lecian
Geometrical qualities of the generalised Schwarzschild spacetimesGeometrical qualities of the generalised Schwarzschild spacetimes
Geometrical qualities of the generalised Schwarzschild spacetimes
Paper Chromatography or Paper partition chromatography by Poonam Aher Patil
Paper Chromatography or Paper partition chromatographyPaper Chromatography or Paper partition chromatography
Paper Chromatography or Paper partition chromatography
Cyanobacteria as a Biofertilizer (BY- Ayushi).pptx by AyushiKardam
Cyanobacteria as a Biofertilizer (BY- Ayushi).pptxCyanobacteria as a Biofertilizer (BY- Ayushi).pptx
Cyanobacteria as a Biofertilizer (BY- Ayushi).pptx
AyushiKardam5 views
AI for automated materials discovery via learning to represent, predict, gene... by Deakin University
AI for automated materials discovery via learning to represent, predict, gene...AI for automated materials discovery via learning to represent, predict, gene...
AI for automated materials discovery via learning to represent, predict, gene...
DNA manipulation Enzymes 2.pdf by NetHelix
DNA manipulation Enzymes 2.pdfDNA manipulation Enzymes 2.pdf
DNA manipulation Enzymes 2.pdf
NetHelix6 views
KeyAI. Solving a math problem to recover lost crypto assets. by RFID INC
KeyAI. Solving a math problem to recover lost crypto assets.KeyAI. Solving a math problem to recover lost crypto assets.
KeyAI. Solving a math problem to recover lost crypto assets.
RFID INC7 views
ELECTRON TRANSPORT CHAIN by DEEKSHA RANI
ELECTRON TRANSPORT CHAINELECTRON TRANSPORT CHAIN
ELECTRON TRANSPORT CHAIN
DEEKSHA RANI18 views
Micelle Drug Delivery System (Nanotechnology).pptx by ANANYA KUMAR
Micelle Drug Delivery System (Nanotechnology).pptxMicelle Drug Delivery System (Nanotechnology).pptx
Micelle Drug Delivery System (Nanotechnology).pptx
ANANYA KUMAR5 views
A giant thin stellar stream in the Coma Galaxy Cluster by Sérgio Sacani
A giant thin stellar stream in the Coma Galaxy ClusterA giant thin stellar stream in the Coma Galaxy Cluster
A giant thin stellar stream in the Coma Galaxy Cluster
Sérgio Sacani23 views
GLUCONEOGENESIS Presentation.pptx by GunjanBaisla
GLUCONEOGENESIS Presentation.pptxGLUCONEOGENESIS Presentation.pptx
GLUCONEOGENESIS Presentation.pptx
GunjanBaisla5 views
Determination of color fastness to rubbing(wet and dry condition) by crockmeter. by ShadmanSakib63
Determination of color fastness to rubbing(wet and dry condition) by crockmeter.Determination of color fastness to rubbing(wet and dry condition) by crockmeter.
Determination of color fastness to rubbing(wet and dry condition) by crockmeter.
ShadmanSakib638 views
Generative AI to Accelerate Discovery of Materials by Deakin University
Generative AI to Accelerate Discovery of MaterialsGenerative AI to Accelerate Discovery of Materials
Generative AI to Accelerate Discovery of Materials
selection of preformed arch wires during the alignment stage of preadjusted o... by MaherFouda1
selection of preformed arch wires during the alignment stage of preadjusted o...selection of preformed arch wires during the alignment stage of preadjusted o...
selection of preformed arch wires during the alignment stage of preadjusted o...
MaherFouda18 views
Exploring_The_Unthinkable_ Franco Gollo.pdf by draconox80
Exploring_The_Unthinkable_ Franco Gollo.pdfExploring_The_Unthinkable_ Franco Gollo.pdf
Exploring_The_Unthinkable_ Franco Gollo.pdf
draconox806 views
COMPLEXOMETRIC TITRATION OR CHEALATOMETRIC TITRATION by Poonam Aher Patil
COMPLEXOMETRIC TITRATION OR CHEALATOMETRIC TITRATIONCOMPLEXOMETRIC TITRATION OR CHEALATOMETRIC TITRATION
COMPLEXOMETRIC TITRATION OR CHEALATOMETRIC TITRATION
Poonam Aher Patil200 views

Graphic Notes on Linear Algebra and Data Science

  • 2. これは何? • Gilbert Strang 著 『Linear Algebra for Everyone』 は線形代数を直感理解するのに とてもいい本です。 • 定理と証明の連鎖ではなく、マトリックス語法と例⽰で直感的な理解と実⽤的な 応⽤法を得ることができます。 • YouTube の MIT Open Courseware、 先⽣の講義プレイリストである 18.06 と 18.065 には、200万⼈の購読者がいます。(ぼくもその⼀⼈です) • この本のハイライトは、 • AB=C の4つの⾒⽅ • 基本的な4つの部分空間 • 5つのマトリックス分解 • 通常の線形代数の教科書はジョルダン標準形がクライマックスですが、この 本では、SVD です。そして、 • 機械学習を含むデータサイエンスへの⼊⾨につながっています。 • この1と2のコンセプトをグラフィック表現できないか、というアイディアです。 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 2 1 2
  • 3. この発表 のモチベ ーション • ⾏列とベクトルの掛け算には、複数の⾒⽅ があります。 • このノートは、それらを可視化し、教育⽤ コンテンツとする試みです。 • それによって ... • ⾏列とベクトルの演算を直感的に⾏えるよう になります。 • その直感を、5つの⾏列分解法、などのコンセ プトの理解につなげることができます。 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 3 最新版︓ https://github.com/kenjihiranabe/The-Art-of-Linear-Algebra/ http://math.mit.edu/everyone
  • 4. 5つの⾏列分解 𝐴 = 𝐶𝑅 𝐴 = 𝐿𝑈 𝐴 = 𝑄𝑅 𝑆 = 𝑄Λ𝑄! 𝐴 = 𝑈Σ𝑉! By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 4 独⽴列⾏列と⾏簡約⾏列の積 (⾏ランク=列ランクを⽰す) LU分解=ガウスの消去法 QR分解=Gram-Schmidtの直⾏化 対称⾏列の固有値分解 どんな⻑⽅⾏列にも使える 特異値分解
  • 5. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 5 Foreword I am happy to see Kenji Hiranabeʻs pictures of matrix operations in linear algebra ! The pictures are an excellent way to show the algebra. We can think of matrix multiplications by (row, column) dot products, but that is not all -- it is ``linear combinations” and ``rank 1 matrices" that complete the algebra and the art. I am very grateful to see the books in Japanese translation and the ideas in Kenji's pictures. -- Gilbert Strang Professor of Mathematics at MIT
  • 6. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 6 • もうすぐ⽇本語訳発売! • ⽇本語訳決定!
  • 7. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 7 先⽣の講演例:https://www.youtube.com/watch?v=MsIvs_6vC38
  • 8. ⽬次 • ⾏列の⾒⽅ – 4つ • ベクトルの積 – 2つ • ⾏列のベクトルの積 – 2つ • ⾏列と⾏列の積 – 4つ • 便利な応⽤パターン– 4つ • ⾏列の有名分解 – 5つ • 𝐶𝑅, 𝐿𝑈, 𝑄𝑅, 𝑄Λ𝑄!, 𝑈Σ𝑉! • データサイエンス応⽤で理解する SVD(今⽇だけ) By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 8
  • 9. = = = 3つの数からなる 2つの列ベクトル 2つの数からなる 3つの⾏ベクトル 6つの数 1 つの⾏列 ⾏列の⾒⽅ – 4つ 𝐴 = 𝑎!!𝑎!" 𝑎"!𝑎"" 𝑎#!𝑎#" = | 𝒂𝟏 | | 𝒂𝟐 | = −𝒂! ∗ − −𝒂" ∗ − −𝒂# ∗ − 以降、太字で列ベクトル𝒂𝟏、*を付けて⾏ベクトル𝒂" ∗ 、を表現する。 また、右肩にTをつけて転置ベクトル𝒂𝐓や転置⾏列𝑨𝐓を表現する。 𝐴 = 1 4 2 5 3 6 = 1 4 2 5 3 6 = 1 4 2 5 3 6 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 9
  • 10. = = = 内積(スカラー) Rank1の⾏列 v1 = 1 2 3 𝑥 𝑦 = 𝑥 𝑦 2𝑥 2𝑦 3𝑥 3𝑦 ベクトルの積 – 2つ 1 2 3 𝑥! 𝑥" 𝑥# = 1 2 3 , 𝑥! 𝑥" 𝑥# = 𝑥! + 2𝑥" + 3𝑥# 2つの列ベクトル𝒂, 𝒃を𝒂𝒃! の順に掛けると、⾏ 列 (𝐴 = 𝒂𝒃! ) になる。 𝒂, 𝒃どちらも0でなければ、 この⾏列はRankが1になることが分かる。(各 ⾏は定数倍であり、各列も定数倍である) 2つの列ベクトルの内積(𝒂 ) 𝒃)は⾏列形 式では、𝒂! 𝒃 と表現され、1つのスカ ラーになる。 v2 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 10
  • 11. = = + ⾏列とベクトルの積 – 2つ 𝐴 の⾏ベクトルと列ベクトルの積 (内積)からなる1つの列ベクトル 𝐴 の列ベクトルの線形結合 𝐴𝒙 = 1 2 3 4 5 6 𝑥! 𝑥" = (𝑥!+2𝑥") (3𝑥! + 4𝑥") (5𝑥! + 6𝑥") 𝐴𝒙 = 1 2 3 4 5 6 𝑥! 𝑥" = 𝑥! 1 3 5 + 𝑥" 2 4 6 最初に左を覚えるだろう。しかし、右の⾒⽅ができるようになると、 𝐴𝒙 が𝐴の列ベクトルの線形結合、すなわち、 𝐴の列ベクトル空間 𝐂(𝐴)、 さらに、 𝐴𝒙 = 0 の解がAの零空間 𝐍(𝐴)と読めるようになる。 Mv 1 Mv 2 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 11
  • 12. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 12
  • 13. ⾏列と⾏列の積 – 4つ = 1 2 3 4 5 6 𝑥" 𝑦" 𝑥# 𝑦# = (𝑥"+2𝑥#) (𝑦"+2𝑦#) (3𝑥"+4𝑥#) (3𝑦"+4𝑦#) (5𝑥"+6𝑥#) (5𝑦"+6𝑦#) 1 2 3 4 5 6 𝑥" 𝑦" 𝑥# 𝑦# = 𝐴 𝒙 𝒚 = 𝐴𝒙 𝐴𝒚 = = 結果の各列 𝐴𝒙, 𝐴𝒚 は、それぞれ𝐴 の列ベクトルの線形結合 結果の各要素は、⾏ベクトルと列ベクトルの内積 MM 1 MM 2 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 13
  • 14. ⾏列と⾏列の積 – 4つ = + = = 1 2 3 4 5 6 𝑏"" 𝑏"# 𝑏#" 𝑏## = 𝒂𝟏 𝒂𝟐 𝒃𝟏 ∗ 𝒃𝟐 ∗ = 𝒂𝟏𝒃𝟏 ∗ + 𝒂𝟐𝒃𝟐 ∗ = 1 3 5 𝑏"" 𝑏"# + 2 4 6 𝑏#" 𝑏## = 𝑏"" 𝑏"# 3𝑏"" 3𝑏"# 5𝑏"" 5𝑏"# + 2𝑏#" 2𝑏## 4𝑏#" 4𝑏## 6𝑏#" 6𝑏## 1 2 3 4 5 6 𝑥" 𝑦" 𝑥# 𝑦# = 𝒂𝟏 ∗ 𝒂𝟐 ∗ 𝒂𝟑 ∗ 𝑋 = 𝒂𝟏 ∗ 𝑋 𝒂𝟐 ∗ 𝑋 𝒂𝟑 ∗ 𝑋 ⾏列の積は、rank 1の⾏列の和に分解される。 結果の各⾏は、⾏ベクトルの線形結合 MM 3 MM 4 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 14
  • 15. 便利な応⽤パターン – 3つ 2 3 = 1 2 3 1 1 = 2 1 + 3 + 2 = 2 1 + 3 + 3 = 2 1 + 3 + MM 2 Mv 2 右からの操作は、列に作⽤する。 この表現は、右の3つの線形結合を 1つの⾏列表現で表したものだとも ⾔える。 P1 using By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 15
  • 16. 1 2 3 = 1 2 3 1 = + 1 2 3 + 2 = + 1 2 3 + 3 = + 1 2 3 + MM 3 左からの操作は、⾏に作⽤する。 この表現は、右の3つの線形結合を 1つの⾏列表現で表したものだとも ⾔える。 P2 using By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 16 便利な応⽤パターン – 3つ
  • 17. = = 𝐴𝐷 = 𝒂𝟏 𝒂𝟐 𝒂𝟑 𝑑! 𝑑" 𝑑# = 𝑑!𝒂𝟏 𝑑"𝒂𝟐 𝑑"𝒂𝟐 𝐷𝐵 = 𝑑! 𝑑" 𝑑# 𝒃! ∗ 𝒃! ∗ 𝒃! ∗ = 𝑑!𝒃! ∗ 𝑑!𝒃! ∗ 𝑑!𝒃! ∗ 対⾓⾏列を右から掛けると各列がスカラー倍 対⾓⾏列を左から掛けると各⾏がスカラー倍 これらを⽬に焼き付けると、さらに、、、、 P1ʼ P2ʼ By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 17 便利な応⽤パターン – 3つ
  • 18. スカラー倍された列ベクトルの線形結合(ベクトル漸化式やベクトル線形微分⽅程式で活⽤) = 𝑿𝑫𝒄 = 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝑑! 𝑑" 𝑑# 𝑐! 𝑐" 𝑐# = 𝑐!𝑑!𝒙𝟏 + 𝑐"𝑑"𝒙𝟐+ 𝑐#𝑑#𝒙𝟑 + + P3 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 18 便利な応⽤パターン – 3つ
  • 19. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 19 微分⽅程式、漸化式の例 P3 𝑋 𝑒*+, Λ, 𝒄 𝒙𝟏 𝒙𝟐 𝒙𝟑
  • 20. = + + 𝑈𝛴𝑉- = 𝒖𝟏 𝒖𝟐 𝒖𝟑 𝜎! 𝜎" 𝜎# 𝒗! - 𝒗" - 𝒗# - = 𝜎!𝒖!𝒗! - + 𝜎"𝒖"𝒗" -+ 𝜎#𝒖#𝒗# - rank 1⾏列の和 (SVDや対称⾏列のスペクトル分解で活⽤) P4 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 20 便利な応⽤パターン – 3つ
  • 21. 𝐴 = 𝐶𝑅 𝐴 = 𝐿𝑈 𝐴 = 𝑄𝑅 𝑆 = 𝑄Λ𝑄! 𝐴 = 𝑈Σ𝑉! By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 21 独⽴列⾏列と⾏簡約⾏列の積 (⾏ランク=列ランクを⽰す) LU分解=ガウスの消去法 QR分解=Gram-Schmidtの直⾏化 対称⾏列の固有値分解 どんな⻑⽅⾏列にも使える 特異値分解 ⾏列の有名分解 – 5つ
  • 22. 𝐴 = 𝐶𝑅 𝐴の列ベクトルを左から順に⾒て、独⽴なもののみ選び出していく。1,2列⽬は⽣き残り、3列⽬は1列⽬+2列 ⽬なので捨てる。残った2つの列ベクトルCを使って𝐴 を復元すると、𝑅には階段⾏列が現れる。 これを、よく⾒て、⼆つの表現で表すと… ⻑⽅⾏列𝐴の⾏ランクと、 𝐴の列ランクが等しいことを最も直感的に⽰す分解。 Cは𝐴の線形独⽴な列ベクトル。 𝑅は⾏簡約階段⾏列(row reduced echelon form)となる。 1 2 3 2 3 5 = 1 2 2 3 1 0 1 0 1 1 | 𝒂𝟏 | | 𝒂𝟐 | | 𝒂𝟑 | = | 𝒄𝟏 | | 𝒄𝟐 | 1 0 1 0 1 1 𝒂𝟏 = 𝒄𝟏, 𝒂𝟐= 𝒄𝟐, 𝒂𝟑 = 𝒄𝟏 + 𝒄𝟐 −𝒂" ∗ − −𝒂# ∗ − = 1 2 2 3 −𝒓" ∗ − −𝒓# ∗ − 𝒂" ∗ = 𝒓" ∗ + 2𝒓# ∗ , 𝒂# ∗ = 2𝒓" ∗ + 3𝒓# ∗ = 2 1 = 1 + 2 1 + 2 1 + 2 すべての列ベクトルはc1,c2の線形結合。すなわち、列ランク=dim C(𝐴)=2。 = + 1 2 1 2 1 2 + = すべての⾏ベクトルはr1,r2の線形結合。すなわち、⾏ランク=dim C(𝐴! )=2。 𝐴 = 𝐶𝑅 P1 P2 using using By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 22
  • 23. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 23 = 2 1 = 1 + 2 1 + 2 1 + 2 1 2 3 2 3 5 = + 1 2 1 2 1 2 + =
  • 24. 𝐴 = | 𝒍𝟏 | −𝒖! ∗ − + 0 0 0 0 0 𝐴" = | 𝒍𝟏 | −𝒖! ∗ − + | 𝒍𝟐 | −𝒖" ∗ − + 0 0 0 0 0 0 0 0 𝐴# = 𝐿𝑈 𝐴 = 𝐿𝑈 𝐴の⾏1ベクトルと列1ベクトルでできる rank 1⾏列を取り出し、サイズが1つ減った⾏列を𝐴# とする。 この操作を再帰的に繰り返して、rank 1 の和に分解する。 = + + 𝐿𝑈 を逆向きに計算して𝐴 に戻すのは容易。 MM 4 ガウスの消去法は、⾏基本変形をAの左から掛けていくが、その逆⾏列が 𝐿である。 using By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 24 = = + + 𝐿 𝑈 𝐴
  • 25. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 25 = = + + 𝐿 𝑈 𝐴 1 2 4 2 1 5 5 1 3
  • 26. = = 𝐴 = 𝑄𝑅 𝐴の各列ベクトルを、Gram-Schmidtの直⾏化によって𝑄 の列ベクトルに直⾏化する。 その際の係数を逆にすることで、𝑅に上三⾓⾏列が作られる。 Gram-Schmidt の直⾏化。 2 3 1 | 𝒂𝟏 | | 𝒂𝟐 | | 𝒂𝟑 | = | 𝒒𝟏 | | 𝒒𝟐 | | 𝒒𝟑 | 𝑟"" 𝑟"# 𝑟"( 𝑟## 𝑟#( 𝑟(( 3 1 + 1 2 + 1 2 + 𝒂𝟏 = 𝑟""𝒒𝟏 𝒂𝟐 = 𝑟"#𝒒𝟏 + 𝑟##𝒒𝟐 𝒂𝟐 = 𝑟"(𝒒𝟏 + 𝑟#(𝒒𝟐 + 𝑟((𝒒𝟑 𝐴 = 𝑄𝑅 P1 using By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 26 𝑄 𝑅 𝐴 𝒂𝟏 𝒂𝟐 𝒂𝟑
  • 27. 𝑆 = 𝑄𝛬𝑄-= | 𝒒𝟏 | | 𝒒𝟐 | | 𝒒𝟑 | 𝜆! 𝜆" 𝜆# −𝒒! - − −𝒒" - − −𝒒# - − =𝜆! | 𝒒𝟏 | −𝒒! - − + 𝜆" | 𝒒𝟐 | −𝒒" - − + 𝜆# | 𝒒𝟑 | −𝒒# - − 𝑆 = 𝑄𝛬𝑄* 対称⾏列𝑆は、直⾏⾏列𝑄によって固有値の対⾓⾏列𝛬に対⾓化される。 さらに、これを rank 1 の射影⾏列の和に分解できる。(スペクトル分解) = 𝜆!𝑃! + 𝜆"𝑃" + 𝜆#𝑃# 対称⾏列𝑆の固有値分解。固有値はすべて実数であり、固有ベクトルは必ず互いに直⾏したものが取れる。 2 3 1 = + + = 1 2 3 1 1 2 2 3 3 P4 using By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 27 𝑄 𝛬 𝑆 𝑄. 𝜆!𝒒𝟏𝒒! . 𝜆"𝒒𝟐𝒒" . 𝜆#𝒒𝟑𝒒# . 𝑆 = 𝑆- 𝑄-𝑄 = 𝑃! +𝑃" + 𝑃# = 𝐼 𝑃!𝑃" = 𝑃"𝑃# = 𝑃#𝑃! = 𝑂
  • 28. 𝐴 = 𝑈Σ𝑉+ 𝐴の⾏空間ℝ) の正規直交基底として𝑉、列空間 ℝ* の正規直交規定として𝑈をそれぞれうまく取ると、対 ⾓化される。これを特異値分解という。さらに、これを rank 1 ⾏列の和に分解できる。 𝐴が⼀般の⻑⽅⾏列の場合でも、特異値分解は必ず可能。 = + = 1 1 2 2 2 3 1 1 2 P4 using By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 28 𝑈 Σ 𝐴 𝑉- 𝜎! 𝒖𝟏𝒗! - 𝜎" 𝒖𝟐𝒗" - 𝑈𝑈- = 𝐼/ 𝑉𝑉- = 𝐼, 𝐴 = 𝑈Σ𝑉-= | 𝒖𝟏 | | 𝒖𝟐 | | 𝒖𝟑 | 𝜎! 𝜎" −𝒗! - − −𝒗" - − =𝜎! | 𝒖𝟏 | − 𝒗! - − + 𝜎" | 𝒖𝟐 | − 𝒗" - − = 𝜎!𝒖𝟏𝒗! - + 𝜎"𝒖𝟐𝒗" -
  • 29. SVDの応⽤からの理解︓ eigenface Washington ⼤学の Steve Brunton 先⽣の YouTube チャネル にて、120回以上の動画で詳しくこの本の中について解説されて いる。その中の、eigenface の回をご紹介。 Databookuw.com By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang
  • 30. Eigenfaces – Yale B Dataset By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 30 256値×32K 画素×64枚× 36⼈、から、特異値ベクトルを抽出
  • 31. ⾏列の2つの意味(1.写像) 𝐴 ∈ 𝑀 𝑚×𝑛, ℝ m⾏n列の実数要素の⾏列 1. ℝ!→ ℝ" の線形写像と⾒る By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 31 ℝ" ℝ# → 𝑥 𝐴 𝐴𝑥 𝑥∈ℝ" n次元列ベクトル 𝐴𝑥∈ℝ# m次元列ベクトル 𝐶 A = 𝐴𝑥 𝑥∈ℝ" } Aの列空間⊂ ℝ# 𝑁 A = 𝑥 𝑥∈ℝ", 𝐴𝑥 = 0} Aの零空間⊂ ℝ" = + 𝐴 の列ベクトルの線形結合 𝑨𝒙 = 1 0 2 1 3 1 𝑥! 𝑥" = 𝑥! 1 2 3 + 𝑥" 0 1 1 Mv 2 rank 𝐴 = dim 𝐶(𝐴) m x n の時、 ℝ% → ℝ& nが⼊⼒m が出⼒であることに注意。
  • 32. ⾏列の2つの意味(2.データ) 2. ℝ" のデータセットが𝑛列と⾒る。 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 32 𝑎$, 𝑎%, … , 𝑎" ∈ ℝ# m次元列ベクトルのデータ 𝑢$, 𝑢%, … , 𝑢# ∈ ℝ# m次元列ベクトルの底 | 𝒂𝟏 | | 𝒂𝟐 | | 𝒂𝟑 | = | 𝒆𝟏 | | 𝒆𝟐 | | 𝒆𝟑 | 1 0 1 2 3 1 1 3 4 2 3 = 1 2 3 1 1 = 2 1 + 3 + 2 = 2 1 + 3 + 3 = 2 1 + 3 + P1 𝒂𝟏 = 𝒖𝟏, 𝒂𝟐 = 𝒖𝟐, 𝒂𝟐 = 𝒖𝟏 + 𝒖𝟐 | 𝒂𝟏 | | 𝒂𝟐 | | 𝒂𝟑 | = | 𝒖𝟏 | | 𝒖𝟐 | | 𝒖𝟑 | 1 0 1 0 0 1 0 1 0 新しい基底(u1,u2,u3)の線形結合として各列を表す 通常の基底(e1,e2,e3)の線形結合として各列を表す 基底 この基底での「座標」 もしくは「成分」が 縦に並ぶ。 各データベクトル 𝑨 = 1 0 1 2 3 1 1 3 4 フーリエ変換等でもデータ圧縮可能 だが、SVDではデータ駆動で(デー タ全体を⾒てから)有効な底を決め る。
  • 33. 固有値/固有ベクトル(復習) 𝐴 ∈ 𝑀 𝑛×𝑛, ℝ n⾏n列の実数要素の正⽅⾏列 1. ℝ!→ ℝ! の線形写像と⾒る By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 33 ℝ" ℝ" → 𝑥 𝐴 𝐴𝑥 ⽅向を変えないベクトルがある。 それらを基底とする(座標は⼲渉しないで定数倍になる)。 𝐴𝒑$ = 𝜆$𝒑$ 𝐴𝒑% = 𝜆%𝒑% 𝐴𝒑& = 𝜆&𝒑& 𝐴𝑥 = 𝜆𝑥 𝐴𝑃 = 𝑃𝛬, 𝐴 = 𝑃𝛬𝑃2! 𝑨 | 𝒑𝟏 | | 𝒑𝟐 | | 𝒑𝟑 | = | 𝒑𝟏 | | 𝒑𝟐 | | 𝒑𝟑 | 𝜆! 𝜆" 𝜆# 1 = 1 1 2 = 2 2 3 = 3 3 1 2 3 2 3 1 2 3 1 = ※必ずn本取れるとは限らない。 対称⾏列なら正規直交なPが必ず取れ、λは実数。
  • 34. 特異値/特異ベクトル 𝐴 ∈ 𝑀 𝑚×𝑛, ℝ m⾏n列の実数要素の⻑⽅⾏列 1. ℝ!→ ℝ" の線形写像と⾒る By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 34 ℝ" ℝ# → 𝑥 𝐴 𝐴𝑥 別の正規直⾏ベクトルを基底とする。 座標は⼲渉しないで定数倍(⾮負の実数)になる。 𝐴𝒗$ = 𝜎$𝒖$ 𝐴𝒗% = 𝜎%𝒖% 𝐴𝒗& = 𝜎&𝒖& 𝐴𝑉 = 𝑈Σ 𝐴 = 𝑈Σ𝑉! 1 = 1 1 2 = 2 2 3 = 3 3 1 2 3 2 3 1 2 3 1 = ※必ず分解でき、⼀意になる。 1 2 3 2 3 1 = 1 2 3
  • 35. 特異値/特異ベクトル 1. 𝑛個の ℝ" のデータセットと⾒る。 By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 35 2 3 1 2 3 1 1 = 2 1 + 3 + 2 = 2 1 + 3 + 3 = 2 1 + 3 + 新基底 各データベクトル (各⾃の顔データ) 2 3 1 = = 新基底 (eigen face) 𝐴 = 𝑈Σ𝑉" 𝐴 = | 𝒖𝟏 | | 𝒖𝟐 | | 𝒖𝟑 | 𝜎& 𝜎' 𝜎( −𝒗& " − −𝒗' " − −𝒗( " − 𝐴 𝑉' 𝑈 Σ (Σ𝑉') 𝑈 = = A の各列(face)は、新基底(eigenface)の線形結合。 A 全体の中での信号の強さが特異値。 データごとの Mixture(Vの⾏) 信号の強さ (特異値) 新基底での座標 (各⾃の顔の成分) 新基底での座標 (各⾃の顔の成分)
  • 36. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 36 ⼿で分解するには、 𝐴'𝐴(どんな𝐴でも対称⾏列となる)を使う。 𝐴 = 𝑈Σ𝑉" 𝐴"𝐴 = (𝑈Σ𝑉")"𝑈Σ𝑉" = 𝑉Σ'𝑉" となり、 𝐴"𝐴(対称⾏列)の対⾓化(固有値)を求めるのと同じ問題に帰着。 1. 𝐴"𝐴 を計算。 2. それを対⾓化、すなわち固有値𝜎'と固有ベクトル 𝒗 をn個求める。 3. それらが、 Σ', 𝑉 となる。 4. Σと𝑉が求まったら、 𝐴𝒗 = 𝜎𝒖 より、𝒗 に対応する 𝒖求めて、 𝑼とする。 これは⼿計算⽤で、通常、コンピュータの数値演算は全く違う ⽅法(シフト付きQRなど) をとる。 特異値/特異ベクトル
  • 37. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 37 直感で SVD 出来ますか︖ 1. 𝐴 = 3 2. 𝐴 = 1 2 3. 𝐴 = 1 3 2 6 直感 or 計算で SVD 出来ますか︖ ポイント 𝐴 = 𝑈Σ𝑉! 単位直⾏⾏列 (⻑さ・⾓度を変えない) (回転と捉えて良い) 対⾓⾏列 (向きを変えない) (スケールと捉えて良い) 𝑈 𝑉 𝑈の次元は? 𝑉の次元は? ℝ" ℝ# 𝐴 ⾏空間 列空間 → = 1 3 1 = 1 5 1 2 5 1 = 1 5 1 −2 2 1 5 0 1 特異値/特異ベクトル
  • 38. Eigenfaces – Yale B Dataset By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 38 256値×32K 画素×64枚× 36⼈、から、特異値ベクトルを抽出
  • 39. 最初の 64 eigenfaces(ちょっと怖い…) By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 39
  • 40. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 40 顔データを元よりも少数 次元の基底によって復元 する。 基底は、U を特異値の⼩ さい⽅を削除ししまった 近似。 このU平⾯に新しい顔を 射影し、その座標(少数) をαという。このαを使っ て、新しい顔を表現する。 (データ圧縮) 顔を次元を順次増 やして復元。 効率は良くないが、 ⽝も表現できるよ。 (だいぶ怖い)
  • 41. 参照⽂献と 謝辞 • Linear Algebra for Everyone (⽇本語 来年) http://math.mit.edu/everyone/ • MIT OpenCourseWare 18.06 http://web.mit.edu/18.06/www/vi deos.shtml • A 2020 Vision of Linear Algebra https://ocw.mit.edu/resources/res -18-010-a-2020-vision-of-linear- algebra-spring-2020/ • マトリックスワールド https://anagileway.com/2020/09/ 29/matrix-world-in-linear-algebra- for-everyone/ • 4つの部分空間 Tシャツ https://anagileway.com/2020/06/ 04/prof-gilbert-strang-linear- algebra/ This work is inspired by Prof. Strangʼs books and lecture videos. I deeply appreciate his work, passion and personality. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 41
  • 42. By Kenji Hiranabe with the kindest help of Prof. Gilbert Strang 42 Tシャツ作った!
  • 43. Thank you for reading! Any comments or feedbacks are welcome to: Kenji Hiranabe (hiranabe@gmail.com) = 43