问题标签 [earth-movers-distance]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
116 浏览

python - 确切的地球移动距离(不是锦葵距离)Python代码

是否有任何用于计算两个签名之间的 EMD 的 python 库?有多个选项可以计算两个分布之间的 EMD(例如 pyemd)。但是我没有找到确切的 EMD 值的任何实现。例如,考虑 Signature_1 = {(1,1), (4,1)} 和 Signature_2 = {(1,1), (2,1), (3,1), (4,1)},其中首先坐标是位置,第二个坐标是权重。True EMD(Signature_1, Signature_2) = 0 而如果我们将这些视为分布,则距离为 0.5(pyemd 中的 emd_samples 给出了这个答案)。但我会对 True EMD 的实现感兴趣。在这方面的任何帮助将不胜感激。

0 投票
0 回答
210 浏览

python - Can scipy.stats.wasserstein_distance be used with empirical distributions of different (unequal) sizes?

For the evaluation of a system, I have measured a metric of interest across three distinct configurations (settings). I thus have three arrays of observations, observations_setting_1, observations_setting_2, and observations_setting_3, for example, looking like this:

The setting which resulted in observations_setting_1 is considered the baseline, while the latter two settings modify some environmental conditions in order to see how the system's performance changes. As you can see from my example, for one of the settings, I had to remove a number of observations due to experiment collection errors (I cannot repeat the experiments at this point).

I would now like to quantify how much the empirical distributions of the metric of interest obtained from settings 2 and 3 deviate from the baseline. The 1st Wasserstein distance (also known as Earth Mover's distance) appears well suited for this. SciPy provides a function to compute the distance: scipy.stats.wasserstein_distance.

My question: Given the differences in number of observations between settings 1 and 2 and setting 3, can I still use the value computed by scipy.stats.wasserstein_distance to make statements about how much setting 3 diverges from setting 1?

In other words, given:

can I make statements about how much setting 3 diverges from baseline setting 1 compared to how much setting 2 diverges from baseline setting 1 despite the difference in lengths of the input arrays? Am I making a statistical mistake if I use SciPy's 1st Wasserstein distance in this way? If that was the case, is there a way for me to fix this?

I would have expected SciPy to reject my input arrays if equal size was a constraint, no error is returned, however.

I appreciate any help on this, thanks already.

0 投票
0 回答
32 浏览

r - 从矩阵和栅格计算 wasserstein 度量

我一直在尝试使用包中的函数计算 wasserstein 指标transport。我有两个高程图层作为 .tif 文件,并且我已将它们栅格化。然后我将它们转换为矩阵,以便它们可以在pgrd函数中使用,然后将矩阵转换为可以在wasserstein函数中使用的格式。当我尝试在wasserstein函数中使用矩阵时,我最终遇到了这个错误。是否有熟悉该transport软件包的人可以阐明此错误?您对从光栅文件计算此指标的其他方法有什么建议吗?

这是我一直在使用的代码:

0 投票
0 回答
32 浏览

python-3.x - 如何计算 Keras 中二维阵列的地球移动器损失?

我一直在寻找如何在 Keras 的二维阵列上实现地球移动器损失。我的输入是 2d(不是图像)。我已经从https://github.com/master/nima/blob/4a685993d0e5942cf70de54f1c31a218827ccba3/nima.py#L31尝试了以下代码, 但它似乎不起作用。任何人都可以帮忙吗?

0 投票
0 回答
26 浏览

python - 在 Tensorflow 1.15 中将地球移动器损失计算为 2D 数组的损失函数时,我收到了这个错误:

这是我在自动编码器中使用的 EMD 损失函数:

而她就是Autoencoder的架构

自动编码器架构

但我收到了这个错误:

ValueError:变量 <tf.Variable 'conv1d/kernel:0' shape=(3, 1, 256) dtype=float32>None用于渐变。请确保您的所有操作都定义了渐变(即可微分)。没有梯度的常见操作:K.argmax、K.round、K.eval。