プリンキピア

第2章準備

2.3.4. Tensors2.3.4 テンソル

While you can go far in your machine learning journey with only scalars, vectors, and matrices, eventually you may need to work with higher-order tensors. Tensors give us a generic way of describing extensions to nth-order arrays. We call software objects of the tensor class “tensors” precisely because they too can have arbitrary numbers of axes. While it may be confusing to use the word tensor for both the mathematical object and its realization in code, our meaning should usually be clear from context. We denote general tensors by capital letters with a special font face (e.g., 𝖷, 𝖸, and 𝖹) and their indexing mechanism (e.g., xijk and [𝖷]1,2i−1,3) follows naturally from that of matrices.
英語のヒント
機械学習の旅は、スカラー、ベクトル、行列だけでもかなり先まで進めるが、いずれはもっと高い階のテンソルを扱う必要が出てくるかもしれない。テンソルは、nth階の配列への拡張を記述する一般的な方法を与える。テンソルクラスのソフトウェアオブジェクトを「テンソル」と呼ぶのは、まさに、それも任意の数の軸をもてるからである。テンソルという言葉を、数学的な対象とコードでの実現の両方に使うのは紛らわしいかもしれないが、意味はたいてい文脈から明らかなはずである。一般のテンソルは特別な字体の大文字(たとえば𝖷、𝖸、𝖹)で表し、そのインデックスの付け方(たとえばxijkや[𝖷]1,2i−1,3)は行列の場合から自然に導かれる。
Tensors will become more important when we start working with images. Each image arrives as a 3rd-order tensor with axes corresponding to the height, width, and channel. At each spatial location, the intensities of each color (red, green, and blue) are stacked along the channel. Furthermore, a collection of images is represented in code by a 4th-order tensor, where distinct images are indexed along the first axis. Higher-order tensors are constructed, as were vectors and matrices, by growing the number of shape components.
英語のヒント
テンソルは、画像を扱い始めるといっそう重要になる。各画像は、高さ、幅、チャネルに対応する軸をもつ3rd階のテンソルとして届く。空間上の各位置で、各色(赤、緑、青)の強さがチャネルに沿って積み重ねられている。さらに、画像の集まりはコードでは4th階のテンソルで表され、異なる画像が最初の軸に沿ってインデックス付けされる。高い階のテンソルは、ベクトルや行列と同じように、形状の成分の数を増やすことで作られる。
torch.arange(24).reshape(2, 3, 4)
tensor([[[ 0,  1,  2,  3],
         [ 4,  5,  6,  7],
         [ 8,  9, 10, 11]],

        [[12, 13, 14, 15],
         [16, 17, 18, 19],
         [20, 21, 22, 23]]])