プリンキピア

第22章付録:深層学習のための数学

22.2.1. Finding Eigenvalues22.2.1 固有値を見つける

Let’s figure out how to find them. By subtracting off the λ𝐯 from both sides, and then factoring out the vector, we see the above is equivalent to:
英語のヒント
それらの見つけ方を考えよう。両辺からλ𝐯を引き、ベクトルをくくり出すと、上の式は次と同値であることがわかる。
(𝐀−λ𝐈)𝐯=0.(22.2.3)
For (22.2.3) to happen, we see that (𝐀−λ𝐈) must compress some direction down to zero, hence it is not invertible, and thus the determinant is zero. Thus, we can find the eigenvalues by finding for what λ is det(𝐀−λ𝐈)=0. Once we find the eigenvalues, we can solve 𝐀𝐯=λ𝐯 to find the associated eigenvector(s).
英語のヒント
式(22.2.3)が成り立つためには、(𝐀−λ𝐈)がある方向を0に押しつぶさなければならないことがわかる。したがって、これは可逆ではなく、行列式は0である。よって、det(𝐀−λ𝐈)=0となるのはどんなλのときかを求めれば、固有値が見つかる。固有値が見つかれば、𝐀𝐯=λ𝐯を解いて、対応する固有ベクトルを見つけられる。

22.2.1.1. An Example22.2.1.1 例

Let’s see this with a more challenging matrix
英語のヒント
もっと難しい行列で、これを見よう。
𝐀=[2123].(22.2.4)
If we consider det(𝐀−λ𝐈)=0, we see this is equivalent to the polynomial equation 0=(2−λ)(3−λ)−2=(4−λ)(1−λ). Thus, two eigenvalues are 4 and 1. To find the associated vectors, we then need to solve
英語のヒント
det(𝐀−λ𝐈)=0を考えると、これは多項式の方程式0=(2−λ)(3−λ)−2=(4−λ)(1−λ)と同値であることがわかる。したがって、二つの固有値は4と1である。対応するベクトルを見つけるには、次を解く必要がある。
[2123][xy]=[xy]and[2123][xy]=[4x4y].(22.2.5)
We can solve this with the vectors [1,−1]⊤ and [1,2]⊤ respectively.
英語のヒント
これは、それぞれベクトル[1,−1]⊤と[1,2]⊤で解ける。
We can check this in code using the built-in numpy.linalg.eig routine.
英語のヒント
組み込みのnumpy.linalg.eigルーチンを使って、コードでこれを確かめられる。
%matplotlib inline
import torch
from IPython import display
from d2l import torch as d2l

torch.linalg.eig(torch.tensor([[2, 1], [2, 3]], dtype=torch.float64))
torch.return_types.linalg_eig(
eigenvalues=tensor([1.+0.j, 4.+0.j], dtype=torch.complex128),
eigenvectors=tensor([[-0.7071+0.j, -0.4472+0.j],
        [ 0.7071+0.j, -0.8944+0.j]], dtype=torch.complex128))
Note that numpy normalizes the eigenvectors to be of length one, whereas we took ours to be of arbitrary length. Additionally, the choice of sign is arbitrary. However, the vectors computed are parallel to the ones we found by hand with the same eigenvalues.
英語のヒント
numpyは固有ベクトルを長さ1に正規化するが、ここでは任意の長さにとったことに注意しよう。さらに、符号の選び方も任意である。しかし、計算されたベクトルは、同じ固有値について手で見つけたベクトルと平行である。