Provably Robust Metric Learning

Lu Wang, Xuanqing Liu, Jinfeng Yi, Yuan Jiang, Cho-Jui Hsieh

TL;DR

Metric learning algorithms often boost classification accuracy at the expense of adversarial robustness, sometimes performing worse than simple Euclidean distance. This paper introduces Adversarial Robust Metric Learning (ARML), a novel framework that learns a provably robust Mahalanobis distance for K-Nearest Neighbor (K-NN) classifiers without sacrificing clean performance.

What Problem Does This Paper Address?

Metric learning aims to find a distance measure that pulls similar items together and pushes dissimilar ones apart, typically to improve K-NN classification. However, these models are notoriously sensitive to adversarial perturbations—tiny, human-imperceptible changes to input data that flip the model's prediction.

While adversarial defense is a hot topic for neural networks, K-NN presents unique challenges:

  1. Non-smoothness: K-NN is a discrete step function. You can't simply "backpropagate" through it to find defenses like you can with neural networks.
  2. Computational Complexity: Evaluating the robustness of K-NN is significantly harder than for neural networks.
  3. The Robustness Trade-off: In neural networks, increasing robustness usually lowers "clean" accuracy. The authors found that popular metric learning methods like Neighborhood Components Analysis (NCA) actually make models less robust than using no metric learning at all (standard Euclidean distance).

Methods

The authors propose finding a Mahalanobis distance $d_M(x, x') = (x-x')^\top M (x-x')$, where $M$ is a positive semi-definite matrix, that maximizes the "minimal adversarial perturbation" for every training sample.

Key Innovations:

  • Differentiable Lower Bound: Since calculating the exact minimal perturbation for K-NN is intractable (NP-hard), the authors derived a novel, differentiable lower bound ($\epsilon^*$) for the Mahalanobis K-NN classifier.
  • ARML Objective: They formulated a training objective that minimizes a loss function based on this lower bound. By using the matrix decomposition $M = G^\top G$, they ensure $M$ remains positive semi-definite during optimization.
  • Efficient Sampling: To handle large datasets, they introduced a sampling strategy that picks "hard" positive and negative neighbors, making the inner min-max optimization much faster.
Decision boundaries of 1-NN with different distances. ARML (c) shows a much more "regularized" and robust boundary compared to NCA (b).

Datasets

The authors evaluated ARML on six diverse public datasets:

  • Small/Medium: Splice, Pendigits, Satimage, and USPS.
  • Image Benchmarks: MNIST and Fashion-MNIST.

These datasets were chosen because metric learning typically performs well on them, providing a strong baseline for testing robustness.

Key Insights and Ideas

  • The "Irony" of Standard Metric Learning: Methods like NCA and LMNN focus so heavily on separating classes in the training set that they create jagged, complex decision boundaries. These boundaries are easily crossed by small perturbations, making the models fragile.
  • No Free Lunch? Not Here: Unlike neural network defenses (like randomized smoothing), ARML does not suffer from a significant trade-off between clean and robust errors. In many cases, it actually improved clean accuracy while simultaneously boosting robustness.
  • Certifiable Robustness: Because the method is based on a mathematical lower bound of the perturbation distance, the robustness of the resulting model is "certifiable"—you can mathematically guarantee that no attack within a certain radius will succeed.

Key Results

ARML consistently outperformed baselines (Euclidean, NCA, LMNN, ITML, LFDA) across all tested radii.

  • Certified Robustness: As shown in the table below, ARML achieved the lowest certified robust errors. For example, on MNIST at an $\ell_2$-radius of 1.5, ARML had a robust error of 0.455, while the next best (Euclidean) was 0.521, and others like LMNN were at 1.0 (total failure).
  • Clean Accuracy: ARML achieved the best clean error (radius 0.000) on 4 out of 6 datasets.
  • Efficiency: Despite the complex math, ARML is highly parallelizable. On a single GPU, it trained on the USPS dataset in just 10.6 seconds.
Table 1: Certified robust errors of Mahalanobis 1-NN. The best (minimum) certified robust errors among all methods are in bold. Note that the certified robust errors of 1-NN are also the optimal empirical robust errors (attack errors), and these robust errors at the radius 0 are also the clean errors.

Limitations and Future Work

  • Linear Constraint: This work focuses on linear metric learning (Mahalanobis distance). While powerful, it doesn't cover non-linear or deep metric learning approaches.
  • K-NN Specific: The theoretical guarantees are specific to K-NN classifiers. Extending these "provable" bounds to other non-parametric models remains an open challenge.
  • Future Directions: The authors suggest that exploring robustness verification for non-linear metric learning (e.g., kernelized or deep metric learning) would be a valuable next step.

Summary updated

BibTeX
@inproceedings{wang2020provably,
  author = {Lu Wang and Xuanqing Liu and Jinfeng Yi and Yuan Jiang and Cho-Jui Hsieh},
  title = {{Provably Robust Metric Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure