Abstract
Traditional kernel methods, such as Support Vector Machines (SVMs), typically rely on the Squared Exponential (RBF) kernel, which uses Euclidean distance to compare data points. However, Euclidean distance is "geometry-blind," failing to account for the spatial relationships inherent in images and shapes. This paper introduces Wasserstein Exponential Kernels, which replace Euclidean distance with the Wasserstein distance from optimal transport theory. By treating images as distributions of mass, these kernels capture structural information that Euclidean metrics ignore. We address the mathematical challenge of ensuring positive semi-definiteness (PSD) and demonstrate that these kernels significantly outperform traditional methods on small-scale datasets like MNIST, USPS, and Quickdraw.
Introduction: The "Geometry-Blind" Problem
In machine learning tasks involving images, the choice of similarity metric is crucial. Standard kernels often rely on the $\ell^2$ (Euclidean) distance, which compares images pixel-by-pixel. This approach is highly sensitive to small spatial perturbations; for instance, shifting a digit by a few pixels can result in a large Euclidean distance, even though the semantic content remains unchanged. To a Euclidean metric, a pixel at coordinate $(10,10)$ has no inherent relationship to a pixel at $(11,11)$ beyond being a distinct feature.
To address this, we propose using the Wasserstein distance (also known as the Earth Mover’s Distance). Unlike Euclidean distance, the Wasserstein metric treats an image as a distribution of mass and calculates the minimum "work" required to transform one distribution into another. This allows the metric to "look around" neighboring pixels, making it inherently robust to deformations and shifts.
The Wasserstein Squared Exponential Kernel
We define the Wasserstein squared exponential kernel as: $$k_W(\alpha, \beta) = \exp\left(-\frac{W_2^2(\alpha, \beta)}{2\sigma^2}\right)$$ where $W_2^2(\alpha, \beta)$ is the squared 2-Wasserstein distance between two distributions $\alpha$ and $\beta$.
While conceptually powerful, this kernel faces a significant mathematical hurdle: for dimensions greater than one, the Wasserstein distance does not naturally define a Reproducing Kernel Hilbert Space (RKHS) because the resulting kernel matrix is not guaranteed to be positive semi-definite (PSD).
Overcoming Mathematical and Computational Hurdles
To make Wasserstein kernels practical, we introduce three key innovations:
- Bandwidth Selection for PSD: We provide a theoretical proof that for any finite dataset, there exists a sufficiently small bandwidth $\sigma$ such that the kernel matrix $K$ is PSD. This ensures the kernel can be used reliably in standard algorithms.
- Wasserstein Feature Maps: For cases where the kernel remains indefinite, we propose a spectral decomposition approach. By truncating negative eigenvalues, we create a finite-dimensional "Wasserstein feature map" that is guaranteed to be PSD, allowing for efficient out-of-sample predictions.
- Entropic Regularization: Exact computation of Wasserstein distance is computationally expensive. We utilize the Sinkhorn algorithm, which adds an entropic regularization term to the transport problem. This enables fast, parallelizable computations, making the kernel feasible for practical use.
Experimental Evaluation and Results
We evaluated the Wasserstein-based Least Squares SVM (LS-SVM) against standard RBF kernels and k-Nearest Neighbor (kNN) benchmarks on three classic datasets: MNIST, USPS, and Quickdraw. We focused on small training sets where structural priors are most beneficial.
Qualitative analysis reveals why the Wasserstein kernel succeeds. As shown in Figure 1, the Wasserstein kernel matrix exhibits a much clearer block-diagonal structure compared to the Euclidean version. This indicates that the Wasserstein metric provides superior class separation by recognizing the underlying geometric similarities within classes.
Discussion and Conclusion
The primary insight of this work is that for shape recognition, relative spatial structure is more informative than absolute pixel values. Wasserstein kernels act as a powerful "structural prior," allowing kernel methods to achieve high accuracy even with limited training data—a regime where deep learning models often struggle without extensive data augmentation.
While computational complexity remains a challenge for scaling to massive datasets, the use of entropic regularization and the discovery that "indefinite" kernels often perform well in practice open new avenues for optimal transport in machine learning. Future work will focus on further optimizing these computations and exploring the integration of Wasserstein priors into deep learning architectures.
Summary updated