Quantum adversarial metric learning model based on triplet loss function

Yanyan Hou, Jian Li, Xiu‐Bo Chen, Chong‐Qiang YearXiv 2023 · DOI · arXiv

TL;DR

Researchers have developed a Quantum Adversarial Metric Learning (QAML) model that uses a triplet loss function to group similar data points while pushing dissimilar ones apart in high-dimensional Hilbert space. By leveraging quantum superposition, the model processes entire "triplets" of data using a single quantum circuit, and it employs quantum gradient ascent to generate adversarial samples, significantly boosting the model's robustness and classification accuracy.

What Problem Does This Paper Address?

Metric learning is the art of teaching a model how to measure "distance" between data points—essential for tasks like face recognition or image clustering. While classical methods are powerful, they often struggle to capture high-order features without losing detail in low-dimensional representations.

Quantum computing offers a solution: embedding data into the exponentially large Hilbert space of qubits. However, two major hurdles remain:

  1. Resource Intensity: Calculating distances between multiple samples usually requires multiple copies of quantum circuits, which is expensive for current hardware.
  2. Vulnerability: Like their classical counterparts, quantum machine learning models are "fragile" and can be easily fooled by adversarial attacks—small, intentional perturbations that lead to incorrect classifications.

This paper introduces a framework that addresses both efficiency and security in the quantum realm.

Methods

The authors propose the Quantum Adversarial Metric Learning (QAML) model. Its architecture is built on three pillars:

  • Quantum Triplet Loss: Instead of comparing just two items, the model looks at a "triplet": an anchor sample, a positive sample (same class), and a negative sample (different class). The goal is to minimize the distance between the anchor and positive while maximizing the distance to the negative.
  • Superposition Parallelism: This is the "secret sauce." Using ancilla (helper) qubits and entanglement, the researchers encode the entire triplet into a single superposition state. This allows a single Parameterized Quantum Circuit (PQC) to calculate all necessary distances simultaneously, drastically reducing the quantum hardware requirements.
  • Adversarial Training via Gradient Ascent: To harden the model, the authors use a quantum gradient ascent method to generate "adversarial anchor samples." These are slightly modified versions of the data designed to confuse the model. By training on these "hard" examples alongside natural ones, the model learns a more resilient metric.

The model uses qubit encoding (mapping data to rotation angles) and is optimized using the parameter shift rule, a technique that allows researchers to calculate gradients directly from quantum measurements.

Datasets

The researchers validated their model using two classic benchmarks:

  1. MNIST: A dataset of handwritten digits. They focused on a binary classification task (distinguishing '0' from '1').
  2. Iris: A famous botanical dataset. They specifically targeted the classes that are traditionally difficult to separate linearly.

Because current quantum simulators (and hardware) have limited qubits, the researchers used Principal Component Analysis (PCA) to reduce the input features before encoding them into the quantum states.

Key Insights and Ideas

  • Efficiency through Entanglement: The ability to process a triplet in a single circuit pass is a significant step toward making quantum metric learning practical for Near-Intermediate Scale Quantum (NISQ) devices.
  • The "Aha" Moment on Robustness: The paper shows that adversarial training doesn't just defend against attacks; it actually forces the model to find a "wider" margin between classes. In the Hilbert space, this translates to more distinct, separable quantum states.
  • Repeated Encoding: The authors found that simply applying a circuit and its conjugate can cancel out effects. To fix this, they introduced a "repeated encoding" step that helps build more complex, high-dimensional features.

Key Results

The simulations, performed using the PennyLane framework, yielded impressive improvements over standard Quantum Metric Learning (QML):

  • Superior Separation: In the MNIST test, the average inner product for different classes dropped significantly in the QAML model compared to standard QML, indicating a much larger "gap" or margin between categories.
  • Robustness Accuracy:
    • On MNIST, the QAML model achieved 100% $\epsilon$-robustness accuracy, compared to 92% for the standard model.
  • On Iris, the QAML model reached 95% robustness, outperforming the standard model's 91%.
  • Generalization: The model showed very little difference in performance between training and test sets, suggesting it generalizes well to unseen data.

Limitations and Future Work

While promising, the study has a few constraints:

  • Scale: The experiments were conducted on small-scale datasets (binary classification) with dimensionality reduction (PCA). Scaling this to multi-class problems with high-resolution images remains a challenge.
  • Simulation vs. Hardware: The results are based on numerical simulations. Real-world quantum noise on actual hardware might impact the precision of the triplet loss calculations.
  • Future Directions: The authors suggest exploring QAML as a subroutine for more complex tasks like unsupervised clustering and more advanced face recognition architectures. They also aim to test the model on actual NISQ hardware to see how it handles physical decoherence and gate errors.

Summary updated

Abstract

Metric learning plays an essential role in image analysis and classification, and it has attracted more and more attention. In this paper, we propose a quantum adversarial metric learning (QAML) model based on the triplet loss function, where samples are embedded into the high-dimensional Hilbert space and the optimal metric is obtained by minimizing the triplet loss function. The QAML model employs entanglement and interference to build superposition states for triplet samples so that only one parameterized quantum circuit is needed to calculate sample distances, which reduces the demand for quantum resources. Considering the QAML model is fragile to adversarial attacks, an adversarial sample generation strategy is designed based on the quantum gradient ascent method, effectively improving the robustness against the functional adversarial attack. Simulation results show that the QAML model can effectively distinguish samples of MNIST and Iris datasets and has higher robustness accuracy over the general quantum metric learning. The QAML model is a fundamental research problem of machine learning. As a subroutine of classification and clustering tasks, the QAML model opens an avenue for exploring quantum advantages in machine learning.
BibTeX
@misc{hou2023quantum,
  author = {Yanyan Hou and Jian Li and Xiu‐Bo Chen and Chong‐Qiang Ye},
  title = {{Quantum adversarial metric learning model based on triplet loss function}},
  year = {2023},
  eprint = {2303.08293},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.08293},
}
Figure