约束优化

Dive into Deep Learning · §35.6

约束优化
拉格朗日乘子 · KKT 条件 · 欧几里得与单纯形投影 · 近端算子与 ISTA · 坐标下降

当最优点的梯度不为零

动机

将 \mathbf{y} = (3, 4) 投影到单位圆盘 g(\mathbf{x}) = \tfrac12(\|\mathbf{x}\|_2^2 - 1) \le 0,即最小化 f(\mathbf{x}) = \tfrac12\|\mathbf{x} - \mathbf{y}\|_2^2:

\nabla f(\mathbf{x}^\star) + 4\,\nabla g(\mathbf{x}^\star) = (-2.4, -3.2) + 4(0.6, 0.8) = \mathbf{0}

  • \mathbf{x}^\star = (0.6, 0.8) 处梯度非零:\nabla f(\mathbf{x}^\star) = (-2.4, -3.2) \neq \mathbf{0}。
  • 力学平衡:没有任何可行移动能降低 f,因为边界外法线 \nabla g(\mathbf{x}^\star) 以乘子 \lambda^\star = 4 反推回来。

等式约束与等值线相切

拉格朗日乘子

考虑在等式曲面 h(\mathbf{x}) = 0(如单位圆周 h(\mathbf{x}) = \tfrac12(\|\mathbf{x}\|^2 - 1) = 0)上最小化可微目标 f(\mathbf{x}):

  • 相交等值线绝非最优:若 f 的等值线穿过 \{h = 0\},则 \nabla f 沿曲面有非零切向分量,提供可行下降方向。
  • 相切条件:在满足 \nabla h(\mathbf{x}^\star) \neq \mathbf{0} 的任意局部极值点 \mathbf{x}^\star 处,f 的等值线与 \{h = 0\} 相切,法向量平行: \nabla f(\mathbf{x}^\star) + \nu^\star\,\nabla h(\mathbf{x}^\star) = \mathbf{0}
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

拉格朗日函数与圆周上的驻点

拉格朗日乘子

将法向量平行与可行性 h(\mathbf{x}) = 0 两项要求打包进关于 (\mathbf{x}, \nu) 的单个函数——拉格朗日函数:

\mathcal{L}(\mathbf{x}, \nu) = f(\mathbf{x}) + \nu\,h(\mathbf{x}) \implies \nabla_{\mathbf{x}}\mathcal{L} = \nabla f(\mathbf{x}) + \nu\,\nabla h(\mathbf{x}) = \mathbf{0}, \qquad \frac{\partial\mathcal{L}}{\partial\nu} = h(\mathbf{x}) = 0

  • 求解单位圆周问题(\mathbf{y} = (3, 4)):
    1. 驻点条件 \nabla_{\mathbf{x}}\mathcal{L} = (\mathbf{x} - \mathbf{y}) + \nu\mathbf{x} = \mathbf{0} 将 \mathbf{x} = \frac{\mathbf{y}}{1 + \nu} 置于过 \mathbf{y} 的射线上。
    2. 可行性 \|\mathbf{x}\|_2 = 1 要求 |1 + \nu| = \|\mathbf{y}\|_2 = 5,给出两解:
      • \nu^\star = +4:\mathbf{x}^\star = (0.6, 0.8),距 \mathbf{y} 为 4(f = 8,全局最小值)。
      • \nu = -6:\mathbf{x} = (-0.6, -0.8),距 \mathbf{y} 为 6(f = 18,全局最大值)。
  • 为何 \nabla h(\mathbf{x}^\star) \neq \mathbf{0} 不可或缺:在 h(x_1, x_2) = x_1^2 + x_2^2 = 0 下求 \min x_1,唯一可行点 \mathbf{0} 有 \nabla f(\mathbf{0}) = (1, 0) 而 \nabla h(\mathbf{0}) = \mathbf{0},不存在乘子 \nu。

超平面最近点与影子价格

拉格朗日乘子

在超平面 h(\mathbf{x}) = \mathbf{a}^\top\mathbf{x} - b = 0 上最小化 f(\mathbf{x}) = \tfrac12\|\mathbf{x}\|_2^2,得 \mathbf{x} = -\nu\mathbf{a} 以及:

\nu^\star = -\frac{b}{\|\mathbf{a}\|^2}, \qquad \mathbf{x}^\star = \frac{b}{\|\mathbf{a}\|^2}\,\mathbf{a}, \qquad p^\star(b) = \frac{b^2}{2\|\mathbf{a}\|^2}

  • 影子价格:对阈值 b 求 p^\star(b) 的导数揭示 \frac{\partial p^\star(b)}{\partial b} = -\nu^\star。

不等式约束:活跃边界与非活跃边界

不等式约束

在实心球 g(\mathbf{x}) = \tfrac12(\|\mathbf{x}\|_2^2 - r^2) \le 0 上最小化 \tfrac12\|\mathbf{x} - \mathbf{y}\|_2^2 分为两种情形:

\mathbf{x}^\star = \frac{\mathbf{y}}{\max\big(1,\, \|\mathbf{y}\|/r\big)}, \qquad \lambda^\star = \max\!\left(0,\, \frac{\|\mathbf{y}\|}{r} - 1\right)

  • 非活跃(g(\mathbf{x}^\star) < 0,\|\mathbf{y}\| < r):\mathbf{x}^\star = \mathbf{y} 落在球内部且 \lambda^\star = 0。
  • 活跃(g(\mathbf{x}^\star) = 0,\|\mathbf{y}\| \ge r):\mathbf{x}^\star = r\mathbf{y}/\|\mathbf{y}\| 落在球面边界上且 \lambda^\star \ge 0。

验证梯度裁剪中的力平衡

不等式约束

对于 \mathbf{y} = (3, 4) 和半径 r = 1,活跃约束公式给出 \lambda^\star = 5/1 - 1 = 4 与 \mathbf{x}^\star = (0.6, 0.8):

x* = [0.6 0.8]  lambda* = 4.0  f(x*) = 8.0
grad f(x*) = [-2.4 -3.2]  lambda* grad g(x*) = [2.4 3.2]  sum = [0. 0.]

为何不等式乘子必须非负(\lambda^\star \ge 0):由于 \nabla g(\mathbf{x}^\star) 从可行集 \{g \le 0\} 指向外部,带 \lambda^\star \ge 0 的平稳性 -\nabla f(\mathbf{x}^\star) = \lambda^\star \nabla g(\mathbf{x}^\star) 确保下降方向 -\nabla f 向外拉向边界墙。若 \lambda^\star < 0,则 -\nabla f 指向内部,步入内部即可降低 f。

四条 Karush–Kuhn–Tucker(KKT)条件

KKT 条件

对于 \min_{\mathbf{x}} f(\mathbf{x}),受约束于 g_i(\mathbf{x}) \le 0 和 h_j(\mathbf{x}) = 0,构造 \mathcal{L}(\mathbf{x}, \boldsymbol{\lambda}, \boldsymbol{\nu}) = f(\mathbf{x}) + \sum_i \lambda_i g_i(\mathbf{x}) + \sum_j \nu_j h_j(\mathbf{x}):

\nabla f(\mathbf{x}^\star) + \sum_{i=1}^m \lambda_i^\star\nabla g_i(\mathbf{x}^\star) + \sum_{j=1}^p \nu_j^\star\nabla h_j(\mathbf{x}^\star) = \mathbf{0}

  • 可行性:原始可行性(g_i(\mathbf{x}^\star) \le 0, h_j(\mathbf{x}^\star) = 0)与对偶可行性(\lambda_i^\star \ge 0)。
  • 互补松弛性:对每个 i 有 \lambda_i^\star g_i(\mathbf{x}^\star) = 0(非活跃边界墙不施力)。

活跃约束的法锥几何

KKT 条件

由互补松弛性,非活跃约束(g_i(\mathbf{x}^\star) < 0)满足 \lambda_i^\star = 0 并从平稳性求和中消失。令 \mathcal{A}(\mathbf{x}^\star) = \{i : g_i(\mathbf{x}^\star) = 0\} 表示活跃集,且 \lambda_i^\star \ge 0:

-\nabla f(\mathbf{x}^\star) = \sum_{i \in \mathcal{A}(\mathbf{x}^\star)} \lambda_i^\star\,\nabla g_i(\mathbf{x}^\star)

  • 法锥:在最优点处,最速下降方向 -\nabla f(\mathbf{x}^\star) 必须位于各活跃边界外法向量 \nabla g_i(\mathbf{x}^\star) 张成的凸锥内。
  • 非凸警示:对于 \min_{x \in [-1, 1]} -x^2,内点 x = 0 配合 \lambda_1 = \lambda_2 = 0 满足全部四条 KKT 条件,但 x = 0 却是全局极大值。
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

约束规范:LICQ 与 Slater 条件

KKT 必要性与充分性

两条正则性条件保证每个局部极小值都是 KKT 点(排除约束梯度退化的边界尖点):

  • 1. 线性无关约束规范(LICQ——一般光滑问题): 在 \mathbf{x}^\star 处所有活跃不等式约束与所有等式约束的梯度 \big\{\nabla g_i(\mathbf{x}^\star) : i \in \mathcal{A}(\mathbf{x}^\star)\big\} \cup \big\{\nabla h_j(\mathbf{x}^\star) : j = 1, \ldots, p\big\}, 线性无关。
  • 2. Slater 条件(凸问题——f, g_i 凸,h_j 仿射): 存在单个严格可行点 \bar{\mathbf{x}} 满足: g_i(\bar{\mathbf{x}}) < 0 \;\text{ (for all non-affine } g_i\text{)}, \qquad g_i(\bar{\mathbf{x}}) \le 0 \;\text{ (for affine } g_i\text{)}, \qquad h_j(\bar{\mathbf{x}}) = 0 \;\forall\,j 验证 Slater 条件只需找到一个内点(例如对任意半径 r > 0 的范数球取 \bar{\mathbf{x}} = \mathbf{0}),无须事先知道 \mathbf{x}^\star。

证明凸性下的 KKT 充分性

KKT 必要性与充分性

对于凸问题(f 和 g_i 凸且可微,h_j 仿射),KKT 条件始终充分以保证全局最优性,完全不需要约束规范:

  • 命题:若 (\mathbf{x}^\star, \boldsymbol{\lambda}^\star, \boldsymbol{\nu}^\star) 满足凸问题的 KKT 条件,则对任意可行 \mathbf{x} 有 f(\mathbf{x}^\star) \le f(\mathbf{x})。
  • 三行证明:
    1. 固定 KKT 乘子并考虑 \varphi(\mathbf{x}) = \mathcal{L}(\mathbf{x}, \boldsymbol{\lambda}^\star, \boldsymbol{\nu}^\star) = f(\mathbf{x}) + \sum_i \lambda_i^\star g_i(\mathbf{x}) + \sum_j \nu_j^\star h_j(\mathbf{x})。由于 \lambda_i^\star \ge 0,\varphi(\mathbf{x}) 是凸函数的非负加权和加上仿射函数,因此 \varphi 在 \mathbb{R}^n 上是凸函数。
    2. 由 KKT 平稳性有 \nabla\varphi(\mathbf{x}^\star) = \mathbf{0},因此 \mathbf{x}^\star 是 \varphi 的无约束全局极小值点:对所有 \mathbf{x} \in \mathbb{R}^n 有 \varphi(\mathbf{x}) \ge \varphi(\mathbf{x}^\star)。
    3. 对任意可行 \mathbf{x}(g_i(\mathbf{x}) \le 0, h_j(\mathbf{x}) = 0),由互补松弛性(\lambda_i^\star g_i(\mathbf{x}^\star) = 0)得: f(\mathbf{x}) \ge f(\mathbf{x}) + \sum_{i=1}^m \lambda_i^\star g_i(\mathbf{x}) + \sum_{j=1}^p \nu_j^\star h_j(\mathbf{x}) = \varphi(\mathbf{x}) \ge \varphi(\mathbf{x}^\star) = f(\mathbf{x}^\star)

闭凸集上的欧氏投影

投影

对于任意非空闭凸集 C \subseteq \mathbb{R}^n,欧氏投影 \Pi_C(\mathbf{y}) 将 \mathbf{y} \in \mathbb{R}^n 映射到 C 中唯一的最近点:

\Pi_C(\mathbf{y}) = \mathop{\mathrm{argmin}}_{\mathbf{x} \in C}\;\tfrac12\|\mathbf{x} - \mathbf{y}\|_2^2

  • 存在性与唯一性:将 C 与以 \mathbf{y} 为中心的闭球求交得到紧集(连续性保证存在性),而 \tfrac12\|\mathbf{x} - \mathbf{y}\|^2 的 1-强凸性保证唯一性。
  • 基本投影的闭式字典:
    • 欧氏球 \{ \|\mathbf{x}\|_2 \le r \}:\Pi_C(\mathbf{y}) = \frac{\mathbf{y}}{\max(1,\, \|\mathbf{y}\|_2 / r)}。
    • 轴对齐盒 [a_i, b_i]:\Pi_C(\mathbf{y})_i = \min\big(b_i, \max(a_i, y_i)\big)(逐坐标裁剪)。
    • 半空间 \{ \mathbf{a}^\top\mathbf{x} \ge b \}:\Pi_C(\mathbf{y}) = \mathbf{y} + \frac{\max(0,\, b - \mathbf{a}^\top\mathbf{y})}{\|\mathbf{a}\|_2^2}\,\mathbf{a}。

钝角变分不等式

投影

点 \hat{\mathbf{x}} \in C 是投影 \Pi_C(\mathbf{y}),当且仅当残差向量 \mathbf{y} - \hat{\mathbf{x}} 与指向 C 内的每条可行弦 \mathbf{x} - \hat{\mathbf{x}} 均成钝角(或直角),即夹角 \ge 90^\circ(\forall\,\mathbf{x} \in C):

\big(\mathbf{y} - \Pi_C(\mathbf{y})\big)^\top\big(\mathbf{x} - \Pi_C(\mathbf{y})\big) \le 0

  • 必要性:沿 (1-\theta)\hat{\mathbf{x}} + \theta\mathbf{x} \in C 移动不能降低 \varphi(\mathbf{x}) = \tfrac12\|\mathbf{x} - \mathbf{y}\|^2,因此 \nabla\varphi(\hat{\mathbf{x}})^\top(\mathbf{x} - \hat{\mathbf{x}}) = (\hat{\mathbf{x}} - \mathbf{y})^\top(\mathbf{x} - \hat{\mathbf{x}}) \ge 0。
  • 充分性:由凸函数 \varphi 的切线界得 \varphi(\mathbf{x}) \ge \varphi(\hat{\mathbf{x}}) + (\hat{\mathbf{x}} - \mathbf{y})^\top(\mathbf{x} - \hat{\mathbf{x}}) \ge \varphi(\hat{\mathbf{x}})。
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

证明投影具有非扩张性

投影

将两点投影到闭凸集 C 上绝不会增大它们之间的欧氏距离:

\|\Pi_C(\mathbf{x}) - \Pi_C(\mathbf{y})\|_2 \le \|\mathbf{x} - \mathbf{y}\|_2

  • 三行证明:将两条钝角不等式 (\mathbf{x} - \mathbf{u})^\top(\mathbf{v} - \mathbf{u}) \le 0 和 (\mathbf{y} - \mathbf{v})^\top(\mathbf{u} - \mathbf{v}) \le 0(其中 \mathbf{u} = \Pi_C(\mathbf{x}), \mathbf{v} = \Pi_C(\mathbf{y}))相加,得到 \|\mathbf{u} - \mathbf{v}\|_2^2 \le (\mathbf{x} - \mathbf{y})^\top(\mathbf{u} - \mathbf{v}),再应用 Cauchy–Schwarz 不等式即可。

投影梯度下降与不动点

投影梯度下降

投影梯度下降(PGD)交替执行梯度步与到 C 上的欧氏投影:

\mathbf{x}_{k+1} = \Pi_C\big(\mathbf{x}_k - \eta\,\nabla f(\mathbf{x}_k)\big)

  • 不动点凭证:\mathbf{x}^\star = \Pi_C(\mathbf{x}^\star - \eta\nabla f(\mathbf{x}^\star)) 当且仅当对所有 \mathbf{x} \in C 有 \nabla f(\mathbf{x}^\star)^\top(\mathbf{x} - \mathbf{x}^\star) \ge 0(不存在可行下降方向;当 f 凸时即为全局最优)。

为何 PGD 的收缩速度不亚于无约束 GD

投影梯度下降

在每次梯度更新后添加投影步骤会拖慢收敛吗?在 \mu-强凸、L-光滑函数(\mu\mathbf{I} \preceq \nabla^2 f(\mathbf{x}) \preceq L\mathbf{I})上,非扩张性保证了与无约束梯度下降完全相同的最坏情况收缩因子 \rho = \max(|1 - \eta\mu|, |1 - \eta L|):

  • 第 1 步:将 \mathbf{x}^\star 写作不动点:\mathbf{x}^\star = \Pi_C\big(\mathbf{x}^\star - \eta\nabla f(\mathbf{x}^\star)\big)。
  • 第 2 步:利用非扩张性消去 \Pi_C: \|\mathbf{x}_{k+1} - \mathbf{x}^\star\| = \big\|\Pi_C(\mathbf{x}_k - \eta\nabla f(\mathbf{x}_k)) - \Pi_C(\mathbf{x}^\star - \eta\nabla f(\mathbf{x}^\star))\big\| \le \big\|(\mathbf{x}_k - \mathbf{x}^\star) - \eta\big(\nabla f(\mathbf{x}_k) - \nabla f(\mathbf{x}^\star)\big)\big\|
  • 第 3 步:应用微积分基本定理:令 \bar{\mathbf{H}} = \int_0^1 \nabla^2 f(\mathbf{x}^\star + t(\mathbf{x}_k - \mathbf{x}^\star))\,dt(\mu\mathbf{I} \preceq \bar{\mathbf{H}} \preceq L\mathbf{I}),则 \|\mathbf{x}_{k+1} - \mathbf{x}^\star\| \le \big\|(\mathbf{I} - \eta\bar{\mathbf{H}})(\mathbf{x}_k - \mathbf{x}^\star)\big\| \le \max\big(|1 - \eta\mu|,\, |1 - \eta L|\big)\,\|\mathbf{x}_k - \mathbf{x}^\star\|

κ = 1000 狭谷上的两阶段 PGD 动力学

投影梯度下降

使用步长 \eta = 1.5 \times 10^{-3} 的 PGD 从 (3, 4) 出发,在半空间 x_1 + x_2 \ge 1 上最小化 f(\mathbf{x}) = \tfrac12(x_1^2 + 1000\,x_2^2)(\mathbf{x}^\star = (\frac{1000}{1001}, \frac{1}{1001}),\lambda^\star = \frac{1000}{1001}):

bound rho = 0.9985   largest ratio in a step = 0.9977
steps to |x - x*| < 1e-6: 738   every step projected from step 733 on
ratio per step on the line: 0.2492   1 - 500.5 eta = 0.2492
grad f at the end = [0.999001 0.999001]
  • 为何是 738 步而非 10{,}200 步? 在首步投影之后,迭代点一直在内部以较慢的速率 1 - \eta = 0.9985 漂移至第 732 步。一旦在第 733 步撞上边界直线 x_1 + x_2 = 1,限制在该直线上的二次函数曲率为 500.5,每步按 1 - 500.5\eta = 0.249 迅速收缩。

向概率单纯形投影(Sparsemax)

单纯形投影

要将分数向量 \mathbf{y} \in \mathbb{R}^n 投影到概率单纯形 \Delta = \{\mathbf{x} \succeq \mathbf{0} : \mathbf{1}^\top\mathbf{x} = 1\},需求解 \min_{\mathbf{x} \in \Delta}\tfrac12\|\mathbf{x} - \mathbf{y}\|^2:

  • KKT 平稳性与松弛性:为 \sum_i x_i = 1 引入乘子 \tau,为 -x_i \le 0 引入乘子 \lambda_i \ge 0,平稳性 x_i - y_i + \tau - \lambda_i = 0 与 \lambda_i x_i = 0 归结为 x_i^\star = \max(y_i - \tau,\, 0),其中 \tau 由单位和预算唯一确定: \sum_{i=1}^n \max(y_i - \tau,\, 0) = 1
  • 精确的 O(n\log n) 排序–阈值算法:排序得 u_1 \ge \cdots \ge u_n,计算 \tau_k = \frac{1}{k}\big(\sum_{j=1}^k u_j - 1\big),并选取满足 u_k > \tau_k 的最大 k。
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

通过顶点检验认证单纯形投影

单纯形投影

由于 x_i(\tau) = \max(y_i - \tau, 0) 与 \lambda_i(\tau) = \max(0, \tau - y_i) 对任意标量 \tau 都满足平稳性、对偶可行性与互补松弛性,仅检查这三条 KKT 残差会被错误的 \tau 欺骗:

x* = [0.666 0.334 0.    0.    0.    0.   ]  zeros: 4  tau = 1.662
tau =  1.662: stationarity 0e+00, comp. slack 0e+00, dual feas. True, sum x = 1.000
tau =  1.962: stationarity 0e+00, comp. slack 0e+00, dual feas. True, sum x = 0.400
certificate max_i (y - x*)^T(e_i - x*) = -3e-16  (<= 0 up to rounding: True)
  • 只有单位和预算 \sum_i x_i = 1 以及在 n 个单纯形顶点 \mathbf{e}_i 上检验的钝角凭证 \max_{1 \le i \le n}(\mathbf{y} - \mathbf{x}^\star)^\top(\mathbf{e}_i - \mathbf{x}^\star) \le 0,才能认证 \mathbf{x}^\star = \Pi_\Delta(\mathbf{y})。

为何次梯度下降无法产生稀疏性

近端算子

lasso 最小化 F(\mathbf{w}) = \tfrac12\|\mathbf{A}\mathbf{w} - \mathbf{b}\|_2^2 + \lambda\|\mathbf{w}\|_1(\mathbf{A} \in \mathbb{R}^{100 \times 8},预设 5 个零权重,\lambda = 3)。若以 \eta = 1/L 运行次梯度下降 \mathbf{w}_{k+1} = \mathbf{w}_k - \eta\big(\mathbf{A}^\top(\mathbf{A}\mathbf{w}_k - \mathbf{b}) + \lambda\,\mathrm{sign}(\mathbf{w}_k)\big),会发生什么?

exact zeros: 0 of 8;  sign flips of the null coordinates, last 20 steps: 95 of 95
largest null coordinate: 0.033;  eta * lam = 0.021

为何次梯度步会在零点附近来回抖动:在预设为零的坐标上,光滑梯度幅值 < \lambda,因此次梯度推力 \pm\eta\lambda 占据主导并几乎每步翻转该坐标符号,最终留下 0 个精确的零。

软阈值化与近端算子

近端算子

近端算子在最小化非光滑凸惩罚 \psi(\mathbf{x}) 与通过二次项锚定在 \mathbf{z} 附近之间取得平衡:

\mathrm{prox}_\psi(\mathbf{z}) = \mathop{\mathrm{argmin}}_{\mathbf{x} \in \mathbb{R}^d}\left(\psi(\mathbf{x}) + \tfrac12\|\mathbf{x} - \mathbf{z}\|_2^2\right)

  • 一维软阈值化(\psi(x) = \lambda|x|):由 Fermat 法则 0 \in \lambda\partial|x| + (x - z) 得 \mathrm{prox}_{\lambda|\cdot|}(z) = \mathrm{sign}(z)\max(|z| - \lambda, 0),在 |z| \le \lambda 上具有精确置零的死区。

近端梯度下降(ISTA)恢复精确零点

近端算子

对于复合目标 F(\mathbf{w}) = s(\mathbf{w}) + \psi(\mathbf{w})(s 凸且 L-光滑,\psi 恰当闭凸),近端梯度下降最小化 s 的 L-光滑二次上界与精确惩罚 \psi 之和:

\mathbf{w}_{k+1} = \mathrm{prox}_{\eta\psi}\big(\mathbf{w}_k - \eta\,\nabla s(\mathbf{w}_k)\big)

exact zeros: 5 of 8;  support recovered: True;  max deviation on the support: 0.029
  • 当 \psi(\mathbf{w}) = \lambda\|\mathbf{w}\|_1 时,该更新即 ISTA(迭代收缩阈值算法):其死区 [-\eta\lambda, \eta\lambda] 恰好吸收了次梯度下降的抖动幅度,干净地恢复全部 5 个预设零点。

lasso 上的循环坐标下降

坐标下降

由于 \|\mathbf{w}\|_1 = \sum_{j=1}^d |w_j| 在坐标间可分,沿单个权重 w_j 最小化 lasso(部分残差 \mathbf{r}_{-j} = \mathbf{b} - \sum_{i \neq j}\mathbf{a}_i w_i,相关性 c_j = \mathbf{a}_j^\top\mathbf{r}_{-j})具有精确闭式解:

w_j \leftarrow \frac{\mathrm{sign}(c_j)\,\max(|c_j| - \lambda,\, 0)}{\|\mathbf{a}_j\|_2^2}

  • 为何坐标扫描胜过 ISTA:每次坐标步使用各自的单列曲率 L_j = \|\mathbf{a}_j\|_2^2 \approx 100,而非全局特征值上限 L = \lambda_{\max}(\mathbf{A}^\top\mathbf{A}) \approx 160,仅需 4–6 轮即可达到 10^{-8},而 ISTA 需 12–25 步。

passes to gap < 1e-8: ISTA 12, coordinate descent 5

概念检验:KKT、单纯形投影与近端算子

检验理解

运用 KKT 与近端法则完成以下三道计算:

  1. 将 \mathbf{y}_1 = (1.5, 2.0) 和 \mathbf{y}_2 = (0.3, 0.4) 投影到单位圆盘 g(\mathbf{x}) = \tfrac12(\|\mathbf{x}\|_2^2 - 1) \le 0 上。两者各自的最优点 \mathbf{x}^\star 与 KKT 乘子 \lambda^\star 是什么?
  2. 将分数向量 \mathbf{y} = (0.9, 0.5, -0.2) 投影到概率单纯形 \Delta 上:哪些坐标存活(k),阈值 \tau 是多少,\Pi_\Delta(\mathbf{y}) 是什么?
  3. 计算 \lambda = 0.7 时软阈值化算子 \mathrm{prox}_{\lambda|\cdot|}(z) 在 z = 0.5 和 z = -2.0 处的取值。

解答:(1) \|\mathbf{y}_1\|_2 = 2.5 > 1(活跃):\lambda^\star = 2.5 - 1 = \mathbf{1.5} 且 \mathbf{x}^\star = \mathbf{y}_1 / 2.5 = \mathbf{(0.6, 0.8)}。\|\mathbf{y}_2\|_2 = 0.5 < 1(非活跃):\lambda^\star = \mathbf{0} 且 \mathbf{x}^\star = \mathbf{(0.3, 0.4)}。(2) 候选阈值 \tau_k = (\sum_{j \le k} y_j - 1)/k:\tau_1 = -0.1 < 0.9(有效),\tau_2 = (1.4 - 1)/2 = 0.2 < 0.5(有效),\tau_3 = 0.2/3 \approx 0.067 \not< -0.2(无效)。故 k = 2,\tau = \mathbf{0.2},\Pi_\Delta(\mathbf{y}) = \mathbf{(0.7, 0.3, 0.0)}。(3) 在 z = 0.5 处,|0.5| \le 0.7 落入死区,因此 \mathrm{prox}_{0.7|\cdot|}(0.5) = \mathbf{0}。在 z = -2.0 处,\mathrm{prox}_{0.7|\cdot|}(-2.0) = -(2.0 - 0.7) = \mathbf{-1.3}。

小结:约束优化与算子

核心要点

问题 / 方法 数学条件 / 更新 最优性 / 速率保证 深度学习与机器学习角色
等式拉格朗日 \nabla f(\mathbf{x}^\star) + \sum_j \nu_j^\star \nabla h_j(\mathbf{x}^\star) = \mathbf{0},h_j = 0 LICQ 下必要;\nu_j^\star = -\partial p^\star/\partial b_j 超平面投影、归一化约束
不等式 KKT 平稳性、原始 / 对偶可行性(\lambda_i^\star \ge 0)、\lambda_i^\star g_i(\mathbf{x}^\star) = 0 凸问题充分;Slater 条件下必要 梯度裁剪、SVM、范数预算正则化
欧氏投影 \Pi_C (\mathbf{y} - \Pi_C(\mathbf{y}))^\top(\mathbf{x} - \Pi_C(\mathbf{y})) \le 0\;\forall\mathbf{x}\in C 唯一且非扩张(\|\Pi_C(\mathbf{x}) - \Pi_C(\mathbf{y})\| \le \|\mathbf{x}-\mathbf{y}\|) PGD \mathbf{x}_{k+1} = \Pi_C(\mathbf{x}_k - \eta\nabla f(\mathbf{x}_k)) 至少与 GD 同速收缩(相同 \rho)
单纯形投影 x_i^\star = \max(y_i - \tau, 0) 且 \sum_i x_i^\star = 1 精确的 O(n\log n) 排序–阈值算法 具有精确零元素的 sparsemax 注意力权重
近端梯度(ISTA) \mathbf{w}_{k+1} = \mathrm{prox}_{\eta\psi}(\mathbf{w}_k - \eta\nabla s(\mathbf{w}_k)) 凸 O(1/k),强凸线性 (1-\mu/L)^k 软阈值化 \mathrm{prox}_{\lambda\|\cdot\|_1} 产生精确权重稀疏性