DeepEMD: A Transformer-based Fast Estimation of the Earth Mover's Distance

Atul Kumar Sinha, François Fleuret

TL;DR

This paper introduces DeepEMD, a novel transformer-based model that efficiently estimates the Earth Mover's Distance (EMD) for point clouds. By leveraging attention mechanisms to predict point-to-point matchings, DeepEMD achieves a significant speedup (up to 100x) over traditional methods while maintaining high accuracy, making it suitable for use as a training loss in deep generative models.

What Problem Does This Paper Address?

The Earth Mover's Distance (EMD) is a powerful metric for comparing point clouds, offering a robust measure of similarity by considering the "work" required to transform one distribution into another. However, its computational complexity, typically $O(N^3)$ using algorithms like the Hungarian method, makes it impractical for use as a loss function during the training of deep learning models, especially for generative tasks where it's needed repeatedly. Consequently, researchers often resort to faster but less accurate surrogates like the Chamfer Distance ($O(N^2)$), which can lead to suboptimal results and miss important global structural information. This paper aims to bridge this gap by providing an efficient and accurate EMD estimation method suitable for deep learning training.

Methods

The core of DeepEMD is a transformer architecture designed to directly predict the bipartite matching between two input point clouds. Instead of directly outputting the EMD value, the model learns to generate an attention matrix that represents the optimal matching between points from the two clouds. This attention matrix is then used to compute the EMD and, crucially, its gradients with respect to point coordinates.

Here's a breakdown of the approach:

  • Input Representation: Two point clouds, $U$ and $V$, are fed into the model. Positional embeddings are added to distinguish points originating from $U$ versus $V$.
  • Transformer Encoder: A multi-head self-attention transformer encoder processes the combined point clouds, creating contextualized representations for each point.
  • Attention-based Matching: A final single-head attention layer predicts an attention matrix. This matrix is interpreted as the bipartite matching between points of $U$ and $V$.
  • Loss Function: The model is trained by minimizing the cross-entropy between the predicted attention matrix and the ground truth matching derived from the exact EMD computation.
  • EMD and Gradient Estimation: Once the matching matrix is predicted, the EMD is calculated as the sum of distances between matched points. The gradients of this EMD with respect to point coordinates are also accurately estimated, which is vital for training generative models.

The paper also proposes a simpler MLP-based baseline that directly predicts the EMD value, but it struggles with gradient estimation and generalization compared to the transformer-based DeepEMD.

Datasets

The authors evaluated DeepEMD on several datasets:

  • Syn2D: A synthetic 2D dataset generated from circles and squares, used to test basic functionality and generalization.
  • ShapeNet: A large-scale 3D CAD model dataset. The experiments focused on specific categories like "airplane," "chair," and "car."
  • ModelNet40: Another 3D object dataset with 40 categories, used to test out-of-distribution generalization by training on one category and testing on others.
  • ScanObjectNN: A real-world point cloud dataset derived from scanned indoor scenes, used for more challenging out-of-distribution evaluations.

The paper also describes augmentations applied to these datasets, including adding noise to point clouds and creating corrupted versions of target point clouds, to improve robustness and test generalization.

Key Insights and Ideas

  • Attention as Matching: The core insight is that attention mechanisms, commonly used for sequence modeling, can be effectively repurposed to predict the bipartite matching required for EMD. This is a novel application of transformers to optimal transport problems.
  • Gradient Estimation is Key: Directly predicting the matching matrix, rather than just the EMD value, allows for accurate gradient estimation. This is crucial for using DeepEMD as a loss function in gradient-based optimization for deep learning models.
  • Out-of-Distribution Generalization: DeepEMD demonstrates remarkable generalization capabilities, performing well even when tested on point clouds from different categories or with different numbers of points than those seen during training, without any fine-tuning. This suggests the model learns a more fundamental understanding of point cloud similarity.
  • EMD as a Training Loss: The ability to efficiently compute EMD and its gradients makes it a viable and superior alternative to Chamfer Distance for training generative models like Variational Autoencoders (VAEs), leading to better reconstruction quality.

Key Results

  • Speedup: DeepEMD achieves a significant speedup of approximately 100x compared to the exact Hungarian algorithm and 40x compared to the Sinkhorn algorithm (with 100 iterations) for point clouds of 1024 points. This is attributed to its $O(N^2)$ complexity versus $O(N^3)$ for Hungarian.
  • Accuracy: DeepEMD consistently provides accurate EMD estimations, outperforming Chamfer Distance and the MLP baseline in terms of correlation and dispersion. It also shows competitive or superior performance to Sinkhorn, especially when Sinkhorn requires many iterations.
  • Matching Quality: The model achieves high cosine similarity between true and estimated gradients, indicating accurate matching.
  • Generalization: DeepEMD shows excellent generalization to unseen point cloud distributions and varying point cloud sizes (up to 8192 points during testing, trained on 1024).
  • VAE Training: When used as a reconstruction loss for a SetVAE, DeepEMD consistently resulted in lower reconstruction EMD compared to training with Chamfer Distance, demonstrating its effectiveness in improving generative model performance.

Limitations and Future Work

  • Quadratic Complexity: While significantly faster than $O(N^3)$, DeepEMD's $O(N^2)$ complexity can still be a bottleneck for extremely large point clouds. The authors suggest exploring faster transformer variants or pooling strategies to further reduce this.
  • Wasserstein-p Metrics: The current work focuses on Wasserstein-2 (EMD). Future work could extend the approach to other Wasserstein-p metrics.
  • Fractional Assignments: The current method enforces bipartite matching (one-to-one correspondence). Extending it to handle fractional assignments (mass splitting), as in the continuous optimal transport problem, could be valuable for certain applications.
  • Architecture Exploration: The paper mentions trying other transformer variants (self-attention, cross-attention, alternating mixtures) and found full attention to be best. Further exploration of architectural choices might yield additional improvements.

Summary updated

BibTeX
@inproceedings{sinha2023deepemd,
  author = {Atul Kumar Sinha and François Fleuret},
  title = {{DeepEMD: A Transformer-based Fast Estimation of the Earth Mover's Distance}},
  booktitle = {TAGML @ ICML},
  year = {2023},
  url = {https://openreview.net/forum?id=MST20kIvhA},
}

Loading related content...

Figure