GithubHelp home page GithubHelp logo

jindi0 / sqnn Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 272 KB

Scalable Quantum Neural Network builds and trains a large-scale QNN in a modular fashion. SQNN is evaluated with a binary classification task on the MNIST dataset.

Python 100.00%
qnn vqc qml

sqnn's Introduction

Scalable Quantum NN

This repo is the code used to produce the results presented in "Scalable Quantum Neural Network" (SQNN).

Content

  • main_qnn.py builds and trains a regular QNN that follows the circuit structure design in TensorFlow Quantum Tutorials, but uses different encoding method (angle encoding).
  • main_sqnn.py builds and trains a SQNN that consists of four identical-sized quantum feature extractors and a quantum predictor. The method of data partitioning is illustrated in Fig.5(1st panel) of our paper.
  • main_differsize.py builds and trains a SQNN that consists of three different-sized quantum feature extractors and a quantum predictor. The method of data partitioning is illustrated in Fig.5(3rd panel) of our paper.
  • data_helper.py includes the functions for data processing.
  • util.py contains the functions for recording intermediate results and quantum circuits.

How to use

Install requitements

    pip install -r requirements.txt

Set hyperparameters

To run the code for the specific tasks, please set the hyperparameters by using the command line or editing the default values of the parameters. The hyperparameters are:

Hyperparameter Description
task The name of the current task. A folder with the same name will be created to store intermediate results.
dataset The name of dataset
seed The random seed used to initialize parameters of VQCs
inputsize The downscaled size (nxn) of input data of QNN. If the model is SQNN, the size is that before data splitting.
clfinputsize For SQNN, the input size of qunatum predictor.
pieces For SQNN, the number of pieces a training instance is splitted into.
lr The learning rate
epoch The number of training epoch
batchsize The size of mini-batch
validation_ratio The ratio of training data that is reserved for validation.

Run scripts

After setting the hyperparameters, run the scripts by using python3.

    python3 scale_qml/main_qnn.py 
    python3 scale_qml/main.sqnn.py
    python3 scale_qml/main_differsize.py

Check results

A folder with the same name as the task will be created after running the script to store results, and a .xls file with the same name as the task will be generated in the folder.

In the .xls file, the 1st column stores the hyperparameters of the current task; the 3rd and 4th column record the accuracy and training loss of each mini-batch; the 6th and 7th column record the accuracy and loss on the validation dataset after each training epoch; 9th and 10th column stores the accuracy and loss on the test dataset after each training epoch.

Contact

If there is any question, please send emails to [email protected].

Citation

If you use this code in your work, please cite our paper.

@inproceedings{wu2022wpscalable,
  title={wpScalable Quantum Neural Networks for Classification},
  author={Wu, Jindi and Tao, Zeyi and Li, Qun},
  booktitle={2022 IEEE International Conference on Quantum Computing and Engineering (QCE)},
  pages={38--48},
  year={2022},
  organization={IEEE}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.