第 22 章 · 符号
Understanding Deep Learning — Notation
This appendix details the notation used in this book. This mostly adheres to standard conventions in computer science, but deep learning is applicable to many different areas, so it is explained in full.
In addition, there are several notational conventions that are unique to this book, including notation for functions and the systematic distinction between parameters and variables. Scalars, vectors, matrices, and tensors
Scalars are denoted by either small or capital letters a, A, α. Column vectors (i.e., 1D arrays of numbers) are denoted by small bold letters a , ϕ, and row vectors as the transpose of column vectors a T, ϕT. Matrices and tensors (i.e., 2D and N D arrays of numbers, respectively) are both represented by bold capital letters B , Φ. Variables and parameters
Variables (usually the inputs and outputs of functions or intermediate calculations) are always denoted by Roman letters a, b , C. Parameters (which are internal to functions or probability distributions) are always denoted by Greek letters α, β, Γ. Generic, unspecified parameters are denoted by ϕ. This distinction is retained throughout the book except for the policy in reinforcement learning, which is denoted by π according to the usual convention. Sets Sets are denoted by curly brackets, so{0, 1, 2} denotes the numbers 0, 1, and 2. The notation{0, 1, 2,...} denotes the set of non-negative integers. Sometimes, we want to specify a set of variables and{ x i}I
本附录详细介绍了本书中使用的符号。这些符号大多遵循计算机科学中的标准约定,但深度学习适用于许多不同领域,因此这里会完整说明。此外,还有一些本书特有的符号约定,包括函数的表示法以及参数与变量之间的系统性区分。
标量、向量、矩阵和张量标量用小写字母或大写字母 a, A, α 表示。列向量(即一维数字数组)用小写粗体字母 a ϕ 表示,行向量则用列向量的转置 a T, ϕT 表示。矩阵和张量(分别为二维和 N 维数字数组)均用粗体大写字母 B Φ 表示。
变量和参数变量(通常是函数或中间计算的输入和输出)始终用拉丁字母 a, b , C 表示。参数(函数或概率分布内部的量)始终用希腊字母 α, β, Γ 表示。通用、未指定的参数用 ϕ 表示。除强化学习中的策略外,本书始终保留这一区分;按照通常约定,该策略用 π 表示。 Sets 集合用花括号表示,因此 {0, 1, 2} 表示数字 0、 1 和 2。记号 {0, 1, 2,...} 表示非负整数集合。有时,我们想指定一组变量,而 { x i}I i=1 表示 I 个变量 x 1,... x I。当不需要指定集合中有多少项时,可简写为 { x i}。记号 { x i, y i}I
i=1 denotes the I variables x 1,... x I. When it’s not necessary to specify how many items are in the set, this is shortened to{ x i}. The notation{ x i, y i}I
i=1 denotes the set of I pairs x i, y i. The convention for naming sets is to use calligraphic letters. Notably, Bt is used to denote the set of indices in a batch at iteration t during training. The number of elements in a set S is denoted by |S|. The set R denotes the set of real numbers. The set R+ denotes the set of non-negative real numbers. The notation RD denotes the set of D-dimensional vectors containing real
i=1 表示 I 对 x i, y i 的集合。集合命名的惯例是使用花体字母。特别地, Bt 用于表示训练过程中在第 t 次迭代时一个批次中的索引集合。集合 S 中的元素个数用 |S| 表示。集合 R 表示实数集。集合 R+ 表示非负实数集。记号 RD 表示 D 维向量集,其中包含实
numbers. The notation RD1×D2 denotes the set of matrices of dimension D1 × D2. The notation RD1×D2×D3 denotes the set of tensors of size D1 × D2 × D3 and so on.
The notation [a, b] denotes the real numbers from a to b, including a and b themselves. When the square brackets are replaced by round brackets, this means that the adjacent value is not included in the set. For example, the set(−π, π] denotes the real numbers from −π to π, but excluding −π.
[a, b] 表示从 a 到 b 的实数,包括 a 和 b 本身。当方括号被替换为圆括号时,表示相邻的值不包含在该集合中。例如,集合 (−π, π] 表示从 −π 到 π 的实数,但不包括 −π。
Membership of sets is denoted by the symbol ∈, so x ∈R+ means that the variable x is a non-negative real number, and the notation Σ ∈RD×D denotes that Σ is a matrix of size D×D. Sometimes, we want to work through each element of a set systematically, and the notation ∀{1,..., K} means “for all” the integers from 1 to K. Functions
Functions are expressed as a name, followed by square brackets that contain the arguments of the function. For example, log[x] returns the logarithm of the variable x. When the function returns a vector, it is written in bold and starts with a small letter. For example, the function y = mlp[ x , ϕ] returns a vector y and has vector arguments x and ϕ. When a function returns a matrix or tensor, it is written in bold and starts with a capital letter. For example, the function Y = Sa[ X , ϕ] returns a matrix Y and has arguments X and ϕ. When we want to leave the arguments of a function deliberately ambiguous, we use the bullet symbol (e.g., mlp[•, ϕ]). Minimizing and maximizing
Some special functions are used repeatedly throughout the text: • The function minx[ f[x]] returns the minimum value of the function f[x] over all possible values of the variable x. This notation is often used without specifying
集合的隶属关系由符号 ∈ 表示,因此 x ∈R+ 表示变量 x 是一个非负实数,而记号 Σ ∈RD×D 表示 Σ 是一个大小为 D×D 的矩阵。有时,我们需要系统地遍历集合中的每个元素,记号 ∀{1,..., K} 表示“对所有”从 1 到 K 的整数。
函数函数由一个名称表示,名称后跟包含函数参数的方括号。例如, log[x] 回报变量 x 的对数。当函数回报一个向量时,它用粗体书写,并以小写字母开头。例如,函数 y mlp[ x ϕ] 回报一个向量 y,并具有向量参数 x 和 ϕ。当函数回报一个矩阵或张量时,它用粗体书写,并以大写字母开头。例如,函数 Y = Sa[ X ϕ] 回报一个矩阵 Y,并具有参数 X 和 ϕ。当我们想要故意让函数的参数保持模糊时,我们使用圆点符号(例如, mlp[•, ϕ])。
the details of how this minimum might be found. • The function argminx[ f[x]] returns the value of x that minimizes f[x], so if y= • The functions maxx[ f[x]] and argmaxx[ f[x]] perform the equivalent operations for
最小化与最大化全文中反复使用了一些特殊函数: • 函数 min x[ f[x]] 返回函数 f[x] 在变量 x 的所有可能取值中的最小值。这种记法通
maximizing functions. Probability distributions
Probability distributions should be written as Pr(x=a), denoting that the random variable x takes the value of a.
However, this notation is cumbersome.
常不说明如何求得该最小值的细节。 • 函数 argmin x[ f[x]] 返回 x 使 f[x] 最小化的取值,因此若 y= argmin x[ f[x]],则
Hence, we usually simplify this and just write Pr(x), where x denotes either the random variable or the value it takes according to the sense of the equation. The conditional probability of y given x is written as Pr(y|x). The joint probability of y and x is written as Pr(y, x). These two forms can be combined, so Pr( y | x , ϕ) denotes the probability of the variable y, given that we know x and ϕ. Similarly, Pr( y , x |ϕ) denotes the probability of variables y and x given that we know ϕ.
When we need two probability distributions over the same variable, we write Pr(x) for the first distribution and q(x) for the second. More information about probability distributions can be found in appendix C. Asymptotic notation
Asymptotic notation is used to compare the amount of work done by different algorithms as the size D of the input increases. This can be done in various ways, but this book only uses big-O notation, which represents an upper bound on the growth of computation in an algorithm. A function f[n] is O[ g[n]] if there exists a constant c>0 and integer n0 such that f[n] < c · g[n] for all n > n0.
• 函数 max x[ f[x]] 和 argmax x[ f[x]] 执行函数最大化的等效操作。
概率分布概率分布应写作 Pr (x=a),表示随机变量 x 取值为 a。然而,这种记法较为繁琐。因此,我们通常会简化这种记法,直接写作 Pr (x),其中 x 根据等式的含义,既可以表示随机变量,也可以表示它所取的值。 y 在给定 x 时的条件概率写作 Pr (y|x)。 y 和 x 的联合概率写作 Pr (y, x)。这两种形式可以结合,因此 Pr (y | x ϕ) 表示变量 y 的概率,前提是我们已知 x 和 ϕ。类似地, Pr (y, x |ϕ) 表示变量 y 和 x 的概率,前提是我们已知 ϕ。当我们需要同一变量上的两个概率分布时,第一个分布写作 Pr (x),第二个分布写作 q (x)。有关概率分布的更多信息可参见附录 C。
渐近记号渐近记号用于比较不同算法在输入规模 D 增大时所完成的工作量。这种比较可以通过多种方式进行,但本书只使用大 O 记号,它表示算法中计算量增长的上界。若存在常数 c>0 和整数 n0,使得对所有 n > n0 均有 f[n] < c · g[n],则函数 f[n] 是 O[ g[n]]。
This notation provides a bound on the worst-case running time of an algorithm. For example, when we say that inversion of a D × D matrix is O[D3], we mean that the computation will increase no faster than some constant times D3 once D is large enough. This gives us an idea of how feasible it is to invert matrices of different sizes. If D= 103, then it may take of the order of 109 operations to invert it. Miscellaneous
A small dot in a mathematical equation is intended to improve ease of reading and has no real meaning (or just implies multiplication). For example, α · f[x] is the same as α f[x] but is easier to read. To avoid ambiguity, dot products are written as a T b (see appendix B.3.4). A left arrow symbol ← denotes assignment, so x←x + 2 means that we are adding two to the current value of x.
这种记号提供了算法最坏情况运行时间的界限。例如,当我们说 D × D 矩阵求逆是 O[D3] 时,意思是当 D 足够大时,计算量不会快于某个常数乘以 D3。这让我们了解对不同大小的矩阵求逆的可行性。如果 D= 103,则求逆可能需要约 109 次操作。
杂项数学公式中的一个小点旨在提高可读性,本身没有实际含义(或仅表示乘法)。例如, α · f[x] 与 α f[x] 相同,但更易读。为避免歧义,点积写作 a T b (见附录 B.3.4)。左箭头符号 ← 表示赋值,因此 x←x + 2 意味着我们在 x 的当前值上加 2。