数式が苦手な人のための準備ページ
A warm-up for those unfamiliar with mathematical notation
線形代数・深層学習・Attention などのページに出てくる数式を読む前に、記号の基本的な意味と読み方を確認するページです。数式を完全に理解する必要はありません。「何のためにある記号か」がわかれば十分です。
A quick orientation to the symbols you'll meet in the linear algebra, deep learning, and Attention pages. You don't need to understand every formula fully — knowing what each symbol is for is enough.
数式は、パズルの暗号ではありません。長い説明を短く書いたメモのようなものです。
A formula isn't a puzzle to decode. Think of it as a compact memo for a longer explanation.
読み方のコツ:記号を追いかけるより、「何をしている式か」を先に見る
Key tip: instead of chasing symbols, ask "what is this formula trying to do?"
たとえば $y = Wx$ という式は、「$x$ という入力を $W$ という重みで変換して $y$ という出力を作る」と読めます。記号そのものより、役割を先につかむのが近道です。
For example, $y = Wx$ says "take input $x$, transform it with weights $W$, and get output $y$." Grasping the role of each symbol first is the fastest path.
物理で $\varepsilon$(イプシロン)を「比例定数」とだけ言われるとピンとこなくても、「電気をためやすさを表す量」と言われると、急に役割が見えてきます。数式の記号も同じです。記号の名前ではなく役割を見てください。
In physics, $\varepsilon$ (epsilon) sounds abstract as "a constant" — but "a measure of how easily a material stores charge" makes the role clear immediately. Math symbols work the same way. Look for the role, not just the name.
式に出てくる $Q$、$K$、$V$、$W$、$x$、$y$ などは、すべて何かの役割の名前です。多くは英単語の頭文字です。
Symbols like $Q$, $K$, $V$, $W$, $x$, $y$ in formulas are all names for roles. Most are initials of English words.
右上に小さく書かれた文字や数字には、2種類あります。混同しないよう確認しておきましょう。
Superscripts (small characters upper-right) have two different meanings. Let's distinguish them.
たとえば、3つの数字を縦に並べたもの(列ベクトル)があるとします:
Suppose you have three numbers stacked vertically (a column vector):
$^\top$ をつけると、縦の並び → 横の並びに変わります(逆も同様)。「向きをくるっと変える」というイメージです。Attention の $QK^\top$ では、$K$ を横向きにすることで $Q$ と「比べやすい形」に揃えています。
Adding $^\top$ converts vertical → horizontal (and vice versa). Think of it as "rotating the layout." In Attention's $QK^\top$, flipping $K$ sideways puts it in the right shape to be compared with $Q$.
数学の掛け算には種類があります。どれを使うかは「何と何を組み合わせているか」で変わります。このページで出てくる3種類を確認しておきましょう。
Mathematical multiplication has several forms, depending on what is being combined. Here are the three kinds you'll see in these pages.
| 種類 | 記号 | 何をするか | 例 | Kind | Symbol | What it does | Example |
|---|---|---|---|---|---|---|---|
| 数どうし | $3 \times 5$ | ふつうの掛け算 | $3 \times 5 = 15$ | Scalars | ordinary multiplication | $3 \times 5 = 15$ | |
| 対応する場所どうし(要素ごと) | $\odot$ または位置を揃えて掛ける | 同じ位置の値を掛けて、全部足す。畳み込みの計算がこれ。 | Sobel フィルタを画像に重ねて掛け合わせる計算 | Element-wise | multiply matching positions, then sum all | The convolution step (Sobel filter × image patch) | |
| 行列積 | $AB$ または $A \cdot B$ | $A$ の 1 行目と $B$ の 1 列目をかけて足す、というのを全ての行・列で繰り返す。 | $y = Wx$(重み行列で入力を変換) | Matrix multiplication | multiply A's rows by B's columns and sum — repeated for all row/column pairs | $y = Wx$ (transform input by weight matrix) |
このページで覚えておくこと: 式の中の掛け算記号をすべて「ふつうの掛け算」と読んでしまうと誤解が生じます。「何と何を組み合わせているか」 を見ると、どの掛け算か判断しやすくなります。
Key takeaway: Treating every multiplication symbol as ordinary multiplication leads to misunderstandings. Ask "what is being combined?" to judge which kind is in use.
式の中に割り算($/$)が出てくると、唐突に感じることがあります。多くの場合、割り算は「値が大きくなりすぎないように落ち着かせる」ために使われます。
When division ($/$) appears in a formula it can feel out of place. Most of the time, division is there to keep values from growing too large.
Attention の式には $\dfrac{QK^\top}{\sqrt{d}}$ という項があります。$Q$ や $K$ が長いベクトルだと、掛け合わせたときの値が大きくなりすぎることがあります。$\sqrt{d}$(ベクトルの長さの平方根)で割ることで、値を扱いやすい大きさに調整しています。
Attention contains the term $\dfrac{QK^\top}{\sqrt{d}}$. When $Q$ and $K$ are long vectors, their product can get very large. Dividing by $\sqrt{d}$ (the square root of the vector length) keeps the values in a manageable range.
最初は「スコアが暴れすぎないようにする調整」と読むだけで十分です。
For now, read it as "a tweak to stop scores from getting too large" and move on.
$\text{softmax}(\cdots)$ のようにかっこがついている場合、かっこの中をひとまとまりとして先に考えます。「かっこの中のものを softmax に渡す」というイメージです。
When you see $\text{softmax}(\cdots)$, treat the parentheses as a "hand this to softmax" instruction. Process the inside first, then feed the result to the function outside.
| 記号 | 読み方 | 意味・役割 | Symbol | Read as | Meaning / role |
|---|---|---|---|---|---|
| $Q, K, V$ | Query・Key・Value | Attention で使う3つの役割の名前 | Query, Key, Value | The three roles in Attention | |
| $W$ | 重み行列 | 「何をどれだけ重視するか」を決める変換行列 | weight matrix | A transformation matrix deciding "how much to value each input" | |
| $x^\top$, $K^\top$ | 転置(トランスポーズ) | 縦と横の向きを入れ替える。乗算ではない。 | transpose | Flip rows and columns. Not a power. | |
| $x^2$ | 2乗(じょう) | 数字が上付きのとき → 何回かける | squared / to the power 2 | A numeric superscript = repeated multiplication | |
| $\sqrt{d}$ | $d$ の平方根 | $d$ を2乗するともとに戻る数。スケール調整でよく使う。 | square root of $d$ | The number that squares back to $d$. Common for scale adjustment. | |
| $\text{softmax}(\cdots)$ | ソフトマックス | 点数の並びを「注目の配分」に変える関数。かっこ内を渡す。 | softmax | Converts a list of scores into an attention distribution. Takes the parenthesised value. | |
| $/$ | 割り算 | ここでは多くの場合「値を小さく調整する」目的で使われる。 | division | Often used here to scale values down to a manageable range. | |
| $AB$ / $A \cdot B$ | 行列積 | 行列どうしを掛け合わせる演算。ふつうの掛け算と手順が異なる。 | matrix multiplication | Multiplying matrices — different procedure from ordinary multiplication. |
ROCm の説明で数式が出てきたら、「この式はどのライブラリの仕事っぽいか?」を一緒に見ると、意味がつながりやすくなります。数式は、計算の担当者を教えてくれる地図として読むこともできます。
When a formula appears in a ROCm explanation, it helps to also ask: "Which library's kind of job is this?" You can read a formula as a map that hints at who is responsible for the computation.
$Wx$ や $AB$ が見えたら: 行列計算なので、ROCm では rocBLAS の出番になりやすいです。
If you see $Wx$ or $AB$: that is matrix math, so rocBLAS is often involved in ROCm.
小さなフィルタや画像パッチが見えたら: 畳み込みなので、MIOpen がどう解くかが大事になります。
If you see small filters or image patches: that is convolution, so how MIOpen solves it becomes important.
$Q, K, V$ や softmax が見えたら: Attention の計算で、内部では大量の行列計算とメモリ移動が起きていると考えると整理しやすいです。
If you see $Q, K, V$ or softmax: think of Attention, where lots of matrix math and memory movement happen underneath.
このページの目的は、式を見たときに「あ、これは役割の名前だな」「これは向きを変えてる記号だな」と気づけるようにすることです。わからない記号が出てきたら、このページに戻って確認するリファレンスとして使ってください。
The goal of this page is simply to help you recognise: "ah, that's a role name" or "that's the flip-the-orientation symbol." Whenever you encounter an unfamiliar symbol in the other pages, come back here as a reference.