A quantum convolutional neural network library.
Project description
Noisy hybrid quantum-classical convolutional neural networks for multi-class image classification
Key features
This library allows to investigate the performance of a noisy hybrid quantum-classical convolutional neural networks and compare it to its classical counterpart.
The library allows to create, train and validate CNNs composed of:
- a single quantum convolutional layer;
- a flattening operation;
- a single fully-connected layer;
- a softmax layer.
As in the classical case, the quantum convolutional layer acts on the input image by extracting sliding blocks from it and performing an operation - called filtering - on each of these blocks. However, unlike the ordinary case, the filtering operation relies upon the execution of a (variational) quantum circuit. More specifically, the $N$ pixel values of each sliding block are mapped into a $N$-qubit variational quantum circuit (VQC) by means of a particular arrangement of non-trainable parametric quantum gates, which compose the so-called "feature map". The remaining part of the VQC, usually referred to as "ansatz", features trainable parametric quantum gates. Finally, the VQC is executed a number of times and measurements in the computational basis on the output quantum state are performed, so to give an estimate for its $2^N$ probability coefficients. The obtained $2^N$ real values are fed into the $2^N$ output images, which are then created by means of a single filter. The number of trainable parameters in the ansatz can be chosen arbitrarily, so that one could in principle explore the chance to obtain better performance with fewer parameters.
The parameters update of the whole net is performed by means of the mini-batch gradient descent algorithm. In order to differentiate the quantum filter's output, the parameter-shift rule is applied.
The whole model is inspired to that proposed by Junhua Liu [1].
Users have to possibility to decide whether to execution the VQC contained within the filter with or without quantum noise. Moreover, they can choose to introduce one or more noise models.
Usage
To use the library, follow the steps below.
- Set the quantum filter architecture (feature map, ansatz, noise etc.), the model hyperparameters (epochs, learning rate etc.), the path of the dataset (dataset_folder_path) and the path of the csv file for saving the evolution of the metrics along the training (csv_path) in the configuration file. The configuration file location is
conf\config.yaml. - Execute
python main.pyin the terminal to start training and validation. The evolution of the metrics along the training procedure are saved incsv_path, indicated in the configuration file.
A default 4-class synthetic dataset of 3x3 images, called 'Tetris', is placed in the root directory of the library. This dataset is composed of 640 training images, 160 validation images and 200 test images. Each image represent a tetris brick. The grey value of the brick pixels is randomly chosen between 0.7 and 1, whereas that of the background pixels between 0 and 0.3.
Author
Giuseppe D'Ambruoso (Lutech S.p.A., University of Bari Aldo Moro).
Acknowledgements
This library was realized with the indinspensable help of dr. Dario del Sorbo (Lutech S.p.A.), dr. Claudio Basilio Caporusso (Lutech S.p.A.), dr. Ivan Palmisano (Lutech S.p.A.), dr. Giuseppe Lamanna (Lutech S.p.A.) and prof. dr. Giovanni Gramegna (University of Bari Aldo Moro). We acknowledge also the support from the whole Lutech R&D 'MILE' pole, directed by dr. Giuseppe Ieva (Lutech S.p.A.).
References
[1] Liu et al. (2021). Hybrid quantum-classical convolutional neural networks. Science China Physics, Mechanics & Astronomy. DOI: 10.1007/s11433-021-1734-3. url: http://dx.doi.org/10.1007/s11433-021-1734-3.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lutech_quantum_cnn-0.1.1.tar.gz.
File metadata
- Download URL: lutech_quantum_cnn-0.1.1.tar.gz
- Upload date:
- Size: 35.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9719fd617bcbf2636d7305e6d4523872e4e7151f8f84ca5dd58925d3e5c19d27
|
|
| MD5 |
18d42407458a6ec4cbefb968edda1bef
|
|
| BLAKE2b-256 |
21eace3633ee4fadfa80b25caff7f47cf86b7d828c1ef4386f06c83d81e94756
|
File details
Details for the file lutech_quantum_cnn-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lutech_quantum_cnn-0.1.1-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4f41294314ac9b1f021f5bbcf69cab1340d46fd1ebf6414f1099c12c9317006
|
|
| MD5 |
0110c6ae6dad014356f736b9f611a1f3
|
|
| BLAKE2b-256 |
6356ed14063b63a67deb7e22506fb4f813d984997203c7d5b0ecbc44b6c73844
|