トップへBack to index

数式が苦手な人のための準備ページ

A warm-up for those unfamiliar with mathematical notation

数式の読み方入門

How to Read Math 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 is a compact memo

数式は、パズルの暗号ではありません。長い説明を短く書いたメモのようなものです。

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.

電気の式で考えてみると: Think of a physics formula:

物理で $\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.

② 文字は「役割の名前」

② Letters are role names

式に出てくる $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.

$Q$Query(質問)
「いま何を知りたいか」を表すベクトル。Attention で使う。
A vector representing "what I am looking for." Used in Attention.
$K$Key(目印)
「各単語がどんな情報を持っているかの目印」を表すベクトル。
A vector representing "what each word holds." Used in Attention.
$V$Value(中身)
「実際に受け渡す情報の中身」。Attention の出力を作るために使う。
The actual content to be passed along. Used to form the Attention output.
$W$Weight(重み)
「何をどれだけ大事にするか」を決める行列。訓練で自動的に決まる。
A matrix deciding "how much to value each input." Learned during training.
$x$input(入力)
入力データ(点数・画素値・単語ベクトルなど)。
Input data — scores, pixel values, word vectors, etc.
$y$output(出力)
計算の結果。$y = Wx$ なら「重みをかけた変換後の値」。
The result of a computation. In $y = Wx$, the transformed value.

③ 右上の小さい文字 — $T$ は「T乗」ではない

③ Superscript — $T$ does not mean "to the power T"

右上に小さく書かれた文字や数字には、2種類あります。混同しないよう確認しておきましょう。

Superscripts (small characters upper-right) have two different meanings. Let's distinguish them.

$x^2$「2乗」"squared"
数字が右上にあるときは「何回かける」という意味。$x^2 = x \times x$。
A number in superscript means "multiply this many times." $x^2 = x \times x$.
$3^2 = 9$、$2^3 = 8$
$3^2 = 9$, $2^3 = 8$
$K^\top$「転置」"transpose"
$T$(または $\top$)が右上にあるとき、これは乗算ではなく「向きを変える」という操作。
When $T$ or $\top$ appears upper-right, it means "flip the orientation" — not multiplication.
縦に並んだ表を横向きにする、横向きを縦向きにする操作。
Turn a column arrangement into a row, or vice versa.

転置($^\top$)をもう少し具体的に

A closer look at transpose ($^\top$)

たとえば、3つの数字を縦に並べたもの(列ベクトル)があるとします:

Suppose you have three numbers stacked vertically (a column vector):

$$\begin{pmatrix}80\\70\\90\end{pmatrix}^\top = \begin{pmatrix}80 & 70 & 90\end{pmatrix}$$

$^\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$.

④ 掛け算も 1 種類じゃない

④ Multiplication comes in more than one flavour

数学の掛け算には種類があります。どれを使うかは「何と何を組み合わせているか」で変わります。このページで出てくる3種類を確認しておきましょう。

Mathematical multiplication has several forms, depending on what is being combined. Here are the three kinds you'll see in these pages.

種類記号何をするか KindSymbolWhat it doesExample
数どうし $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.

⑤ 割り算は「大きさを調整する」

⑤ Division adjusts scale

式の中に割り算($/$)が出てくると、唐突に感じることがあります。多くの場合、割り算は「値が大きくなりすぎないように落ち着かせる」ために使われます。

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 の $\sqrt{d}$ による割り算

Example: dividing by $\sqrt{d}$ in Attention

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.

⑥ かっこは「先にここをまとめる」

⑥ Parentheses mean "do this part first"

$\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.

$\text{softmax}(QK^\top)$ を順番に読む

Reading $\text{softmax}(QK^\top)$ step by step

$QK^\top$ まず Q と K(横向きに変換済み)を掛けてスコアを作る First, multiply Q and K (transposed) to get scores
$\text{softmax}(\cdots)$ そのスコアを softmax に渡して「注目の配分」に変える Pass those scores to softmax to get the attention distribution
$\text{softmax}(QK^\top)\,V$ さらに V を掛けて、配分にしたがった情報を集める Multiply by V to collect information according to the distribution

⑦ 記号クイックリファレンス

⑦ Symbol quick reference

記号読み方意味・役割 SymbolRead asMeaning / 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 のページで数式を見るときのコツ

⑧ A trick for reading formulas on ROCm pages

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.

見分け方の目安

A simple way to tell

$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.

最後に:記号を全部覚えなくていい

Final note: you don't need to memorise all the symbols

このページの目的は、式を見たときに「あ、これは役割の名前だな」「これは向きを変えてる記号だな」と気づけるようにすることです。わからない記号が出てきたら、このページに戻って確認するリファレンスとして使ってください。

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.

次に読む
Next read

イメージでわかる線形代数

Visual Linear Algebra

ベクトル・行列・行列積を比喩で解説

Vectors, matrices, and matrix multiply through analogy

次に読む
Next read

イメージでわかる深層学習

Visual Deep Learning

畳み込み・フィルタ・MIOpen を図で解説

Convolution, filters, and MIOpen through diagrams

次に読む
Next read

イメージでわかる Attention

Visual Attention for Beginners

LLM の核心 Attention を比喩で解説

Attention — the core of LLMs — through analogy