Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.gitignore various changes Sep 12, 2019
README.md ref [2] title in italic Oct 2, 2019
quantum_weights.pt qpu testing code Sep 12, 2019
run_on_QPU.py fixes all PauliZ expvals to the new notation of PL Dec 6, 2019

README.md

High-resolution image classification with real quantum computers.

This folder contains the code that has been used in the paper [1] to experimentally classify high-resolution images of ants and bees with real quantum processors provided by IBM and Rigetti.

The model is a hybrid neural network composed of a classical block (ResNet18) and a variational "dressed quantum circuit" [1], which has been numerically optimized according to the classical-to-quantum (CQ) transfer learning paradigm.

This code is based on the cross-platform library PennyLane [2] and can be used to test the optimized model with two alternative quantum processing units (QPUs):

  1. IBM Q 5, Tenerife (ibmq4x).
  2. Rigetti Aspen-4-4Q-A.

Contents

  • run_on_QPU.py: Python script to run the hybrid classical-quantum image classifier with IBM or Rigetti quantum processors.

  • quantum_weights.pt: Pre-trained model loaded by run_on_QPU.py to initialize the variational parameters of the hybrid network.

Usage

To test the model with the IBM backend:

  1. Make sure to satisfy all requirements (see next section).
  2. Download or clone the repository.
  3. Download the Hymenoptera dataset as described in the main README file this repository.
  4. Edit the local file run_on_QPU.py and set backend = 'ibm'.
  5. Moreover, set your personal IBM token by editing token = '<your token>'.
  6. Launch the script with the command $ python3 run_on_QPU.py.
  7. The output files results_ibm.txt and predictions_ibm.png will be generated.

To test the model with the Rigetti backend, you will first need to reserve QPU time:

  1. Make sure to satisfy all requirements (see next section).
  2. Login to the Rigetti QCS and your quantum machine image (QMI).
  3. Download or clone the repository in the QMI.
  4. Download the Hymenoptera dataset as described in the main README file of this repository.
  5. Edit the file run_on_QPU.py and set backend = 'rigetti'.
  6. Launch the script with the command $ python3 run_on_QPU.py.
  7. The output files results_rigetti.txt and predictions_rigetti.png will be generated.

Requirements

Running the model with the Rigetti backend requires having a Rigetti QCS account with access to a remote quantum machine image (QMI). In the QMI, the Python library PennyLane should be installed together with the associated PyTorch and Rigetti plugins.

Running the model with the IBM backend requires having an IBM Q Experience account and a local installation of the Qiskit SDK. The Python library PennyLane should be installed together with the associated PyTorch and IBM plugins.

References

[1] Andrea Mari, Thomas R. Bromley, Josh Izaac, Maria Schuld, Nathan Killoran, Transfer learning in hybrid classical-quantum neural networks. arXiv:xxxx.xxxx, (2019).

[2] Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, Carsten Blank, Keri McKiernan, and Nathan Killoran. PennyLane: Automatic differentiation of hybrid quantum-classical computations. arXiv:1811.04968, (2018).

You can’t perform that action at this time.