Papers
Topics
Authors
Recent
Search
2000 character limit reached

Bidirectional Earth Mover Distance Loss

Updated 9 July 2026
  • Bidirectional EMD loss is an optimal transport-based objective that compares distributional differences via symmetric and asymmetric formulations.
  • It leverages cumulative histogram methods and normalization to enforce geometry in output spaces across diverse applications like NeRF and point cloud learning.
  • Practical implementations use directional weighting and differentiable surrogates to improve numerical stability, convergence, and matching fidelity.

Bidirectional Earth Mover Distance (EMD) loss denotes a family of optimal-transport-based training objectives built around the Earth Mover’s Distance, i.e., the 1-Wasserstein distance, but interpreted in more than one way across the literature. In the balanced setting, where the compared measures have equal total mass, EMD is symmetric, so a formally “bidirectional” loss obtained by summing both argument orders is redundant and reduces to a constant multiple of the same metric. In practice, however, the phrase is also used for asymmetric generalizations that penalize opposite transport directions differently, for unbalanced variants that relax mass conservation, and for learned or regularized surrogates that average both input orders to enforce symmetry or improve matching fidelity in neural training pipelines (List, 2021, Martinez et al., 2016, Shenoy et al., 2023, Sinha et al., 2023, Rau et al., 2024).

1. Formal definition and relation to Wasserstein geometry

For discrete measures PP and QQ with equal total mass, classical balanced EMD is the minimum-cost transport problem

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,

with d(i,j)d(i,j) given by a ground metric. In continuous form, for probability measures μ,ν\mu,\nu, the same object is the 1-Wasserstein distance

W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).

This establishes EMD as an optimal transport metric rather than a binwise discrepancy, which is why it encodes output-space geometry directly into the loss (Martinez et al., 2016, Shenoy et al., 2023).

In one dimension, EMD admits a closed form in terms of cumulative distribution functions. For probability measures u,vu,v on R\mathbb{R} with CDFs U,VU,V,

W1(u,v)=RU(t)V(t)dt.W_1(u,v)=\int_{\mathbb{R}} |U(t)-V(t)|\,dt.

For discrete ordered histograms QQ0 and QQ1, with cumulative histograms QQ2 and QQ3, the standard discrete 1D EMD is

QQ4

With non-uniform bin widths QQ5, the corresponding discretization becomes

QQ6

This QQ7 formulation is the basis of several practical losses for histogram regression and depth-distribution supervision (List, 2021, Rau et al., 2024).

For chain-connected output spaces, the same structure appears as cumulative mass imbalance along adjacent edges. If QQ8 and QQ9 is the consecutive edge cost, then

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,0

Tree-connected label spaces admit an analogous decomposition over subtree mass differences, which allows hierarchical EMD losses to respect ontology structure such as WordNet (Martinez et al., 2016).

2. Symmetry, redundancy, and the meaning of “bidirectional”

The central fact behind the term is that balanced EMD is symmetric: minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,1 Accordingly, if predictions and targets are normalized to equal mass, a bidirectional loss of the form

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,2

reduces to

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,3

For 1D histograms, this means that explicitly computing “both directions” adds no information. The same observation is made in settings as different as histogram regression, detector-image compression, NeRF depth supervision, and chain- or tree-structured classification (List, 2021, Martinez et al., 2016, Shenoy et al., 2023, Rau et al., 2024).

This symmetry depends on equal-mass transport. The cited works therefore normalize outputs to the probability simplex, to charge fractions, or to per-ray termination distributions summing to one. In NeRF supervision, the standard weights minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,4 are normalized as

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,5

precisely so that symmetric EMD applies along each ray. In compression for HGCAL, inputs are normalized by total charge so that

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,6

again ensuring balanced transport (Rau et al., 2024, Shenoy et al., 2023).

The term “bidirectional” becomes substantive only when symmetry is absent or only approximately realized. Three situations recur. First, mass mismatch motivates unbalanced OT. Second, asymmetric losses deliberately weight opposite discrepancy directions differently. Third, approximate neural surrogates may not satisfy exact transport constraints, so averaging both input orders can reduce bias or enforce metric symmetry. DeepEMD is a clear example: its predicted attention is row-normalized but not column-constrained, so it is trained and evaluated in both directions. Likewise, a learned EMD CNN for calorimeter images enforces symmetry by construction through

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,7

These are architectural uses of bidirectionality, not changes to the underlying balanced metric (Shenoy et al., 2023, Sinha et al., 2023).

3. Asymmetric extensions: Earth Mover’s Pinball loss and unbalanced transport

A principal asymmetric generalization is the Earth Mover’s Pinball (EMP) loss, introduced for histogram-valued regression. It applies the scalar pinball loss

minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,8

to cumulative histogram discrepancies minT0  i=1Kj=1KTijd(i,j)s.t.T1=P,T1=Q,\min_{T \ge 0}\;\sum_{i=1}^{K}\sum_{j=1}^{K} T_{ij}\, d(i,j) \quad \text{s.t.} \quad T\,\mathbf{1} = P,\qquad T^{\top}\mathbf{1}=Q,9, yielding

d(i,j)d(i,j)0

At d(i,j)d(i,j)1,

d(i,j)d(i,j)2

so median EMP is equal to EMD up to a constant factor. The paper states that this constant factor does not change the optimum and can be ignored or folded into the learning rate; with that understanding, median EMP recovers the standard EMD (List, 2021).

EMP is asymmetric for d(i,j)d(i,j)3. Specifically,

d(i,j)d(i,j)4

in general, while

d(i,j)d(i,j)5

This replaces redundant bidirectional EMD with a controlled directional preference. The cited formulation interprets d(i,j)d(i,j)6 as penalizing underestimation of cumulative mass more heavily, and d(i,j)d(i,j)7 as penalizing overestimation more heavily. A symmetrized EMP can be formed by averaging the two directions,

d(i,j)d(i,j)8

which recovers EMD at d(i,j)d(i,j)9 (List, 2021).

A different departure from symmetry arises when the compared objects do not have equal total mass. In that case classical EMD is undefined, and unbalanced OT augments transport with marginal relaxations, for example

μ,ν\mu,\nu0

This construction is motivated in settings with leftover background mass, occlusion-induced truncation, or non-normalized energy. The cited NeRF work does not use unbalanced OT, because it normalizes per-ray weights and uses a single symmetric EMD/Sinkhorn term; the detector-compression work similarly recommends normalization unless preserving absolute energy is part of the objective, in which case an additional energy penalty may be added (Rau et al., 2024, Shenoy et al., 2023).

4. Gradients, relaxations, and differentiable optimization

In one dimension, exact EMD and EMP are amenable to direct backpropagation through cumulative sums. For EMP, with μ,ν\mu,\nu1, the pinball subgradient is

μ,ν\mu,\nu2

with subgradient at μ,ν\mu,\nu3 any value in μ,ν\mu,\nu4. Propagated to per-bin predictions,

μ,ν\mu,\nu5

For discrete 1D EMD with bin widths μ,ν\mu,\nu6,

μ,ν\mu,\nu7

almost everywhere. These formulas explain why cumsum-based implementations are both exact and computationally light in ordered spaces (List, 2021, Rau et al., 2024).

Nonsmoothness is a recurrent obstacle. One response is smoothing. EMP admits a softplus approximation

μ,ν\mu,\nu8

where μ,ν\mu,\nu9. As W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).0, the gradients recover pinball subgradients. Another response is relaxation. For chain-connected or tree-connected outputs, the relaxed loss

W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).1

is proposed, with W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).2 recommended as EMDW1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).3. The cited analysis argues that W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).4 yields smooth, real-valued gradients with nonzero Hessians, improving convergence while preserving mass. In reduced-data ImageNet-1k experiments, this relaxed EMD loss achieved better Top-1 accuracy than cross entropy loss (Martinez et al., 2016).

A second response is entropic regularization. Sinkhorn Distance replaces the linear program with

W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).5

which is differentiable and solved by iterative matrix scaling. The cited analysis, however, emphasizes W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).6 memory and per-iteration cost, sensitivity to the iteration limit, float32 numerical issues caused by the exponential kernel, and practical gradient asymmetry unless W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).7 is large and iterations are ample. Bidirectional averaging can damp numerical asymmetry, but the underlying stability problem remains (Martinez et al., 2016).

A third response is to learn a differentiable surrogate. In detector compression, a CNN is trained to regress exact POT EMD values and then frozen as a loss; in point clouds, DeepEMD trains a Transformer to predict the matching matrix itself rather than the scalar EMD, because this gives accurate gradients with respect to point coordinates. Both strategies are explicitly designed to make EMD-like training feasible when exact optimal transport is too slow or insufficiently differentiable for repeated use inside a training loop (Shenoy et al., 2023, Sinha et al., 2023).

5. Neural implementations across domains

In histogram-valued regression, the standard workflow is: normalize predicted outputs with softmax to obtain a density histogram, compute cumulative sums, form cumulative residuals, apply pinball per bin, and sum over bins. The paper further describes quantile conditioning by feeding W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).8 as an extra input and sampling W1(μ,ν)=infγΠ(μ,ν)xydγ(x,y).W_1(\mu,\nu)=\inf_{\gamma\in\Pi(\mu,\nu)} \int \|x-y\|\,d\gamma(x,y).9 per batch element so that all quantiles can be learned simultaneously. Because cumulative histograms are monotone and bounded in u,vu,v0, this formulation yields monotone cumulative outputs within u,vu,v1 and exposes uncertainty via quantile bands rather than only a single median prediction (List, 2021).

In NeRF, EMD is applied not to rendered depth expectations but to the full ray termination distribution. Along a ray,

u,vu,v2

with discretized weights

u,vu,v3

After normalization, u,vu,v4 defines a per-ray distribution that is aligned to a depth prior u,vu,v5 using EMD or a Sinkhorn proxy. The cited system weights photometric and EMD supervision by a diffusion-derived uncertainty u,vu,v6: u,vu,v7 This design explicitly downweights EMD where depth priors are unreliable and upweights RGB, and vice versa (Rau et al., 2024).

In HGCAL data compression, exact EMD is first computed offline with POT’s ot.emd2 on 340,000 pairs of HGCAL wafer samples, split 70\%/30\% train/validation, using charge fractions so that transport is balanced. A CNN surrogate then approximates EMD from remapped calorimeter images. The optimized architecture uses four 2D convolutional layers, each with 32 filters and u,vu,v8 kernels, each followed by BatchNorm and ReLU, then a fully-connected layer with 256 units, BatchNorm and ReLU, and finally order-averaging to enforce symmetry. This frozen network is subsequently used as the autoencoder loss (Shenoy et al., 2023).

In point cloud learning, DeepEMD concatenates two point clouds, adds a learned cloud-ID positional embedding, and applies a Transformer encoder. A single-head scaled dot-product attention layer produces an attention matrix whose top-right and bottom-left blocks represent two directional match distributions. Training minimizes row-wise cross-entropy in both directions against Hungarian bipartite matchings. At inference, the method computes an averaged bidirectional cost from hard row-wise argmax matches, while a soft transport interpretation is also available for smooth gradients. Here bidirectionality is not redundant bookkeeping: it compensates for the fact that the predicted attention is row-normalized but not doubly stochastic (Sinha et al., 2023).

6. Empirical behavior, common misconceptions, and limitations

Across the cited works, EMD-based objectives consistently outperform purely per-bin or pointwise losses when the target has ordered or geometric structure. In histogram regression, the predicted median histograms obtained with EMP at u,vu,v9 have accuracy very similar to the standard EMD case and higher than per-bin loss functions such as cross-entropy, while the predictions become much more informative at almost no additional computational cost. On the football task, EMP yields calibrated quantile bands for cumulative histograms over positions, whereas a naive per-bin Gaussian likelihood fails because of non-monotone quantiles and infinite support issues. In the astrophysical computer vision problem, training with EMP across all R\mathbb{R}0 produces median predictions comparable to training only with EMD at R\mathbb{R}1, but provides uncertainty via quantile bands “for free,” with reported training overhead for learning all R\mathbb{R}2 below 10\% wall time (List, 2021).

In NeRF depth supervision, EMD-guided training on ScanNet reduces AbsRel to 0.070, SqRel to 0.024, RMSE to 0.221, and RMSE log to 0.105, improving over SCADE at 0.086/0.030/0.252/0.118 and DäRF at 0.151/0.071/0.356/0.168, while maintaining photometric performance with PSNR R\mathbb{R}3. On ScanNet+, RMSE drops from 1.032 for SCADE and 1.765 for DäRF to 0.456 with EMD guidance, with PSNR R\mathbb{R}4. The cited interpretation is that supervising distributions rather than expected depth better tolerates multimodality and prior uncertainty (Rau et al., 2024).

In detector compression, the EMD CNN surrogate achieves approximately 5\% resolution relative to exact EMD, with validation R\mathbb{R}5 of relative difference approximately 5.3\% and small bias approximately R\mathbb{R}6. When used as the training loss, the median EMD between input and output wafers improves by 35\% versus weighted MSE and 28\% versus telescope MSE for R\mathbb{R}7, with an overall approximately 25\% improvement relative to prior best telescope-MSE-based training. Downstream, effective RMS in transverse-momentum resolution decreases by 13\% at R\mathbb{R}8 relative to telescope MSE. In point clouds, DeepEMD reports wall-clock speed-ups of more than two orders of magnitude with respect to exact Hungarian matching and one order of magnitude with respect to the standard approximate Sinkhorn algorithm, while yielding gradient cosine-similarity distributions concentrated near 1 and maintaining strong out-of-distribution behavior (Shenoy et al., 2023, Sinha et al., 2023).

A common misconception is that “bidirectional EMD loss” always denotes a distinct metric. In the balanced case it does not: summing both argument orders either reproduces the same scalar up to a factor of two or serves as a symmetry-enforcing device for an approximation. Genuine directionality enters only when asymmetry is introduced intentionally, as in EMP with R\mathbb{R}9, or when mass conservation is relaxed, as in unbalanced OT (List, 2021, Martinez et al., 2016).

The limitations are similarly domain-specific. The 1D identity between Wasserstein-1 and an U,VU,V0 distance between CDFs is special, so extending EMP directly to multi-dimensional histograms requires careful treatment of cumulative ordering and ground distances. Sinkhorn remains sensitive to regularization and floating-point precision in large output spaces. Learned surrogates inherit domain specificity: the HGCAL surrogate depends on fixed geometry remappings, and DeepEMD does not enforce column sums on its predicted attention. In NeRF, even though EMD is more robust than U,VU,V1, extremely poor priors can still misguide training if uncertainty is misestimated. These caveats delimit where bidirectional formulations are mathematically redundant, where they are algorithmically useful, and where a directional or unbalanced alternative is the more principled choice (Martinez et al., 2016, Shenoy et al., 2023, Sinha et al., 2023, Rau et al., 2024).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Bidirectional Earth Mover Distance (EMD) Loss.