Wasserstein距离
推土机距离问题(Earth Mover's Distance)
假设地面上有
我们现在要把土从
矩阵的第
而矩阵的第
因此传输方案
假设从
如果把
Wasserstein距离
把上述问题推广到连续的情况,考虑归一化后的情况,那么(1.1)可以改写为: $$\int p(x)dx =\int q(x)dx=1\tag{1.5}$$
(1.2)式为: $$p(x)=\int \gamma(x,y)dy\tag{1.6}$$
(1.3)式为: $$p(y)=\int \gamma(x,y)dx\tag{1.7}$$
在这种情况下,传输方案
由于
因此,最优传输的目的就是在所有可能的联合概率密度里面,找到花费最小的,使之能够以最小的代价把分布从
如果我们取花费函数为欧式距离时
称为Wasserstein-
称为Wasserstein距离或者W距离,后面的讨论主要也是以W距离为主。
如果花费为正,那么W距离恒大于等于0;并且当
对偶问题
(1.10)是一个带有下确界的优化函数,有时候不好操作,但我们可以利用线性规划的对偶性将其进行转化一下。首先我们可以把
那么(1.10)就能写成列向量的内积形式: $$W^1=\inf_{\Gamma } \Gamma \cdot C\tag{1.12}$$
对应的约束(1.6)和(1.7)就可以写为: $$\underbrace{\left[ \begin{array}{ccc|ccc|c|ccc} 1 & 1 & \cdots & 0 & 0 &\cdots & \cdots & 0 & 0 & \cdots \ 0 & 0 & \cdots & 1 & 1 &\cdots & \cdots & 0 & 0 & \cdots \ \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \cdots & \vdots & \vdots & \ddots \ 0 & 0 & \cdots & 0 & 0 &\cdots & \cdots & 1 & 1 & \cdots \ \hline 1 & 0 & \cdots & 1 & 0 &\cdots & \cdots & 1 & 0 & \cdots \ 0 & 1 & \cdots & 0 & 1 &\cdots & \cdots & 0 & 1 & \cdots \ \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \cdots & \vdots & \vdots & \ddots \ 0 & 0 & \cdots & 0 & 0 &\cdots & \cdots & 0 & 0 & \cdots \ \end{array} \right]}{A} \underbrace{ \begin{bmatrix} \gamma(x_1, y_1) \ \gamma(x_1, y_2) \ \vdots \ \hline \gamma(x_2, y_1) \ \gamma(x_2, y_2) \ \vdots \ \hline \vdots \ \hline \gamma(x_n, y_1) \ \gamma(x_n, y_2) \ \vdots\ \end{bmatrix}}{\Gamma} = \underbrace{\left[ \begin{array}{c} p(x_1) \ p(x_2) \ \vdots \ p(x_n) \ \hline q(y_1) \ q(y_2) \ \vdots \ q(y_n) \ \end{array} \right]}{b} \tag{1.13}$$
那么最终(1.10)就可以写成线性规划的形式: $$\min{\Gamma} \left{ \Gamma\cdot C \mid A\Gamma = b, \Gamma \geq 0 \right}\tag{1.14}$$
根据线性规划的(强)对偶性(可以参考《https://zhuanlan.zhihu.com/p/681165783 (opens new window)》): $$\min_{x} {c^T x \mid Ax = b, x \geq 0}=\max_{y} {b^T y \mid A^T y \leq c} \tag{1.15}$$
(1.14)的对偶问题为: $$\max_{F} {b^T F \mid A^T F \leq C}\tag{1.16}$$
其中,
为什么最优传输
那么我们为什么要计算 optimal transport 呢?如果为了 measure 概率分布之间的距离,有很多现成的 measurements 可以用, 比如非常简单的 KL 散度:
除了 “无法处理两个分布的支撑集不相交的情况”以及“不满足对称性” 等原因之外,一个重要的原因就是这种 逐点计算的度量 没有考虑分布内的结构信息。 所谓的结构信息,就是分布内的联系。例如在 KL 散度中,
就以我们常见的分类任务为例,分类任务通常用交叉熵损失来度量模型预测和样本标签之间的距离, 交叉熵损失实际上就是在计算 onehot 化的标签和模型预测之间的 KL 散度。 这种逐点计算的损失函数(不论是交叉熵还是 L2)都无法考虑分布内不同事件的相关性。 例如将“汽车”误分类成“卡车”显然没有把“汽车”误分类成“斑马”严重。 但是用 KL 散度来度量的话,这两种错误的损失是一样的。
概率分布内的结构信息可以通过最优传输的距离矩阵