XanaduAI / quantum-transfer-learning

A transfer learning approach applied to hybrid neural networks composed of classical and quantum elements.
Apache License 2.0
70 stars 35 forks source link

Transfer learning in hybrid classical-quantum neural networks

A transfer learning approach applied to hybrid neural networks composed of classical and quantum elements.

This repository contains the source code related to the research paper "Transfer learning in hybrid classical-quantum neural networks" arXiv:1912.08278 (2019).

Figure

Contents

Usage

To visualize the content of the Jupyter notebooks without running the code there are two alternatives:

  1. Navigate with a browser to the GitHub repository and simply click on the notebook file. GitHub will automatically visualize the notebook, however the rendering may not be good (especially for LaTeX formulas).
  2. Copy the URL of the notebook file and paste it into nbviewer.

To open and run a local copy of a notebook one should apply the following steps:

  1. If missing, install JupyterLab.
  2. Run the command:
    $ jupyter notebook
  3. Navigate to the local notebook file and open it.

For the usage of the code in quantum_processors\ see the dedicated README file quantum_processors\README.md.

Requirements

Software

All notebooks require the installation of JupiterLab with a Python 3 kernel. In addition the library matplotlib is required for generating plots and images.

The notebook dressed_circuit.ipynb requires the Python library PennyLane.

The notebooks c2q_transfer_learning_*.ipynb require the Python libraries PennyLane and PyTorch.

The notebooks q2c_transfer_learning.ipynb and q2q_transfer_learning.ipynb require the library Strawberry Fields with the TensorFlow backend.

Notebooks can be run using the package versions specified in the requirements.txt file.

For the requirements of the code in quantum_processors\ see the dedicated README file quantum_processors\README.md.

Datasets

The notebook c2q_transfer_learning_ants_bees.ipynb and the code in quantum_processors\ require to manually download the dataset, consisting of the Hymenoptera subset of ImageNet (ants and bees). The dataset can be downloaded here and should extracted in the subfolder \data\hymenoptera_data\.

The notebook c2q_transfer_learning_cifar.ipynb will automatically download the CIFAR10 dataset.

The datasets (random quantum states) for the notebooks q2q_transfer_learning.ipynb and q2q_transfer_learning.ipynb are automatically generated on the fly, during the training and testing phases.

Authors

Andrea Mari, Thomas R. Bromley, Josh Izaac, Maria Schuld, and Nathan Killoran.

If you are doing any research using this source code, please cite the following paper:

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

License

This source code is free and open source, released under the Apache License, Version 2.0.