基本定义
argmax 是数学中广泛使用的运算符,表示使函数取得最大值时的自变量取值。其标准形式为:
$$ \underset{x}{\operatorname{arg,max}} f(x) $$
读作"the argument of the maximum",表示当函数 $f(x)$ 取得最大值时,变量 $x$ 的取值。
数学表达式
给定一个函数 $f: X \to \mathbb{R}$,其中 $X$ 是定义域,则:
$$ \underset{x \in X}{\operatorname{arg,max}} f(x) = { x \in X \mid f(x) = \sup_{x’ \in X} f(x’) } $$
当最大值存在且唯一时,可以简写为: $$ x^* = \underset{x}{\operatorname{arg,max}} f(x) $$
与max的区别
max返回的是函数的最大值本身argmax返回的是使函数达到最大值的自变量值
示例: $$ \begin{align*} \max_{x \in [-1,1]} x^2 &= 1 \ \underset{x \in [-1,1]}{\operatorname{arg,max}} x^2 &= {-1, 1} \end{align*} $$
多解情况
当最大值在多个点取得时,argmax 返回一个集合:
$$ \underset{x}{\operatorname{arg,max}} \cos(x) = {2k\pi \mid k \in \mathbb{Z}} $$
常见变体
带约束的argmax: $$ \underset{x \in C}{\operatorname{arg,max}} f(x) $$ 其中 $C \subseteq X$ 是约束集
多变量argmax: $$ \underset{(x,y)}{\operatorname{arg,max}} f(x,y) $$
带权重的argmax: $$ \underset{x}{\operatorname{arg,max}} \sum_{i=1}^n w_i f_i(x) $$
在机器学习中的应用
分类器决策: $$ \hat{y} = \underset{y}{\operatorname{arg,max}} P(y \mid \mathbf{x}) $$
参数估计(最大似然估计): $$ \hat{\theta} = \underset{\theta}{\operatorname{arg,max}} P(\mathcal{D} \mid \theta) $$
强化学习中的策略选择: $$ \pi(s) = \underset{a}{\operatorname{arg,max}} Q(s,a) $$
计算实现
Python示例
| |
矩阵运算中的argmax
| |
数学性质
平移不变性: $$ \underset{x}{\operatorname{arg,max}} (f(x) + c) = \underset{x}{\operatorname{arg,max}} f(x) $$
正缩放不变性: $$ \underset{x}{\operatorname{arg,max}} (kf(x)) = \underset{x}{\operatorname{arg,max}} f(x), \quad k > 0 $$
单调函数变换: 若 $g$ 严格单调增,则: $$ \underset{x}{\operatorname{arg,max}} g(f(x)) = \underset{x}{\operatorname{arg,max}} f(x) $$
相关概念
argmin:求函数最小值点的运算符
softmax:可微分的近似argmax函数 $$ \text{softmax}(x)_i = \frac{e^{x_i}}{\sum_j e^{x_j}} $$
top-k argmax:寻找前k个最大值的点
注意事项
- 当函数无界时(如 $f(x) = x$ 在 $\mathbb{R}$ 上),argmax 可能不存在
- 在离散情况下,argmax 可能返回空集(如定义域为空时)
- 数值计算中需注意浮点精度问题
张芷铭的个人博客
💬 评论