プリンキピア

第2章準備

2.3.11. Norms2.3.11 ノルム

Some of the most useful operators in linear algebra are norms. Informally, the norm of a vector tells us how big it is. For instance, the ℓ2 norm measures the (Euclidean) length of a vector. Here, we are employing a notion of size that concerns the magnitude of a vector’s components (not its dimensionality).
英語のヒント
線形代数で最も役立つ演算子のいくつかはノルムである。くだけた言い方をすれば、ベクトルのノルムは、そのベクトルがどれほど大きいかを教えてくれる。たとえばℓ2ノルムは、ベクトルの(ユークリッド)長さを測る。ここでは、ベクトルの成分の大きさにかかわる(次元数ではない)大きさの概念を使っている。
A norm is a function ∥⋅∥ that maps a vector to a scalar and satisfies the following three properties:
英語のヒント
ノルムとは、ベクトルをスカラーに写し、次の三つの性質を満たす関数∥⋅∥である。
  1. Given any vector 𝐱, if we scale (all elements of) the vector by a scalar α∈ℝ, its norm scales accordingly:
    英語のヒント
    任意のベクトル𝐱について、ベクトル(のすべての要素)をスカラーα∈ℝ倍すると、そのノルムもそれに応じて伸び縮みする。
    ∥α𝐱∥=|α|∥𝐱∥.(2.3.10)
  2. For any vectors 𝐱 and 𝐲: norms satisfy the triangle inequality:
    英語のヒント
    任意のベクトル𝐱と𝐲について、ノルムは三角不等式を満たす。
    ∥𝐱+𝐲∥≤∥𝐱∥+∥𝐲∥.(2.3.11)
  3. The norm of a vector is nonnegative and it only vanishes if the vector is zero:
    英語のヒント
    ベクトルのノルムは非負であり、ベクトルがゼロのときに限り0になる。
    ∥𝐱∥>0 for all 𝐱≠0.(2.3.12)
Many functions are valid norms and different norms encode different notions of size. The Euclidean norm that we all learned in elementary school geometry when calculating the hypotenuse of a right triangle is the square root of the sum of squares of a vector’s elements. Formally, this is called the ℓ2 norm and expressed as
英語のヒント
多くの関数が正当なノルムであり、異なるノルムは異なる大きさの概念を表す。小学校の幾何で直角三角形の斜辺を計算するときに誰もが習ったユークリッドノルムは、ベクトルの要素の二乗和の平方根である。形式的には、これはℓ2ノルムと呼ばれ、次のように表される。
∥𝐱∥2=∑i=1nxi2.(2.3.13)
The method norm calculates the ℓ2 norm.
英語のヒント
normメソッドはℓ2ノルムを計算する。
u = torch.tensor([3.0, -4.0])
torch.norm(u)
tensor(5.)
The ℓ1 norm is also common and the associated measure is called the Manhattan distance. By definition, the ℓ1 norm sums the absolute values of a vector’s elements:
英語のヒント
ℓ1ノルムもよく使われ、それに対応する尺度はマンハッタン距離と呼ばれる。定義により、ℓ1ノルムはベクトルの要素の絶対値を足し合わせる。
∥𝐱∥1=∑i=1n|xi|.(2.3.14)
Compared to the ℓ2 norm, it is less sensitive to outliers. To compute the ℓ1 norm, we compose the absolute value with the sum operation.
英語のヒント
ℓ2ノルムと比べると、外れ値の影響を受けにくい。ℓ1ノルムを計算するには、絶対値と和の演算を組み合わせる。
torch.abs(u).sum()
tensor(7.)
Both the ℓ2 and ℓ1 norms are special cases of the more general ℓp norms:
英語のヒント
ℓ2ノルムとℓ1ノルムはどちらも、より一般的なℓpノルムの特別な場合である。
∥𝐱∥p=(∑i=1n|xi|p)1/p.(2.3.15)
In the case of matrices, matters are more complicated. After all, matrices can be viewed both as collections of individual entries and as objects that operate on vectors and transform them into other vectors. For instance, we can ask by how much longer the matrix–vector product 𝐗𝐯 could be relative to 𝐯. This line of thought leads to what is called the spectral norm. For now, we introduce the Frobenius norm, which is much easier to compute and defined as the square root of the sum of the squares of a matrix’s elements:
英語のヒント
行列の場合、話はもっと複雑である。なにしろ行列は、個々の成分の集まりとしても、ベクトルに作用して別のベクトルに変換する対象としても見ることができる。たとえば、行列とベクトルの積𝐗𝐯が𝐯と比べてどれだけ長くなりうるかを問うことができる。この考え方の筋道は、スペクトルノルムと呼ばれるものにつながる。今は、フロベニウスノルムを紹介する。これはずっと計算しやすく、行列の要素の二乗和の平方根として定義される。
∥𝐗∥F=∑i=1m∑j=1nxij2.(2.3.16)
The Frobenius norm behaves as if it were an ℓ2 norm of a matrix-shaped vector. Invoking the following function will calculate the Frobenius norm of a matrix.
英語のヒント
フロベニウスノルムは、行列の形をしたベクトルのℓ2ノルムであるかのように振る舞う。次の関数を呼び出すと、行列のフロベニウスノルムが計算される。
torch.norm(torch.ones((4, 9)))
tensor(6.)
While we do not want to get too far ahead of ourselves, we already can plant some intuition about why these concepts are useful. In deep learning, we are often trying to solve optimization problems: maximize the probability assigned to observed data; maximize the revenue associated with a recommender model; minimize the distance between predictions and the ground truth observations; minimize the distance between representations of photos of the same person while maximizing the distance between representations of photos of different people. These distances, which constitute the objectives of deep learning algorithms, are often expressed as norms.
英語のヒント
あまり先走りはしたくないが、これらの概念がなぜ役立つのかについて、すでにいくらか直観を植えつけておける。深層学習では、最適化問題を解こうとすることがよくある。観測データに割り当てる確率を最大にする。推薦モデルに伴う収益を最大にする。予測と正解の観測値との距離を最小にする。同じ人物の写真の表現どうしの距離を最小にしつつ、異なる人物の写真の表現どうしの距離を最大にする。深層学習アルゴリズムの目的を構成するこれらの距離は、しばしばノルムとして表される。