ExperimentIntermediateQuantum machine learning

Variational Quantum Classifier on Simple Blobs

A two-layer VQC learns to separate two blobs; the loss decreases and accuracy rises, with gradients from the parameter-shift rule.

Goal

Follow the training of a variational quantum model and read the loss and accuracy curves.

Approximate duration: 8 minutes

Steps

  1. Choose the blobs data, two layers and 30 epochs.
  2. Run training and watch the loss.
  3. Compare training accuracy with test accuracy.
  4. Change the learning rate to 0.5, then 0.01, and note its effect.
Loading the simulator…
What theory predicts

Theory predicts that the training loss generally decreases over the epochs, and that test accuracy on these separable data reaches a high value (the simulation engine was checked to reach at least 90% with the default settings). The exact values depend on the seed and the data split.

The model: angle encoding $R_Y(x_i)$, then $L$ layers of $R_Y(\theta)$ and $R_Z(\theta)$ on each qubit followed by CNOTs. The output $\langle Z_0\rangle$ is converted to a probability $P(\text{class }1)=(1-\langle Z_0\rangle)/2$, and binary cross-entropy (BCE) is used as the loss. Derivatives from the Parameter-shift Rule are exact because the simulation has no shot noise, and the optimiser is Adam.

The data are synthetic, nearly linearly separable “blobs”, so success on them is expected for any reasonable classifier, including logistic regression. Simulation results on small datasets do not prove any quantum advantage over classical machine learning.

Test your understanding

The quiz needs JavaScript.

Related topics

References

  1. Maria Schuld; Alex Bocharov; Krysta M. Svore; Nathan Wiebe (2020). Circuit-centric quantum classifiers. Phys. Rev. A 101:032308 doi:10.1103/PhysRevA.101.032308
  2. K. Mitarai; M. Negoro; M. Kitagawa; K. Fujii (2018). Quantum circuit learning. Phys. Rev. A 98:032309 doi:10.1103/PhysRevA.98.032309
  3. Marcello Benedetti; Erika Lloyd; Stefan Sack; Mattia Fiorentini (2019). Parameterized quantum circuits as machine learning models. Quantum Sci. Technol. 4:043001 doi:10.1088/2058-9565/ab4eb5
  4. Diederik P. Kingma; Jimmy Ba (2014). Adam: A Method for Stochastic Optimization. arXiv:1412.6980 doi:10.48550/arXiv.1412.6980