Skip to main content

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.

  1. 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.
  2. Execute python main.py in the terminal to start training and validation. The evolution of the metrics along the training procedure are saved in csv_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.

Metadata

Release files for lutech-quantum-cnn 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lutech-quantum-cnn 0.1.1
File Size Uploaded Provenance Actions
lutech_quantum_cnn-0.1.1.tar.gz 35.4 kB Without provenance Details for lutech_quantum_cnn-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lutech-quantum-cnn 0.1.1
File Interpreter ABI Platform Actions
lutech_quantum_cnn-0.1.1-py3-none-any.whl Python 3 none any Details for lutech_quantum_cnn-0.1.1-py3-none-any.whl

Total release size: 69.2 kB

Release files / lutech_quantum_cnn-0.1.1.tar.gz

Download URL lutech_quantum_cnn-0.1.1.tar.gz
Size 35.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9719fd617bcbf2636d7305e6d4523872e4e7151f8f84ca5dd58925d3e5c19d27
BLAKE2b-256 checksum
How to use checksums
21eace3633ee4fadfa80b25caff7f47cf86b7d828c1ef4386f06c83d81e94756
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / lutech_quantum_cnn-0.1.1-py3-none-any.whl

Download URL lutech_quantum_cnn-0.1.1-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4f41294314ac9b1f021f5bbcf69cab1340d46fd1ebf6414f1099c12c9317006
BLAKE2b-256 checksum
How to use checksums
6356ed14063b63a67deb7e22506fb4f813d984997203c7d5b0ecbc44b6c73844
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for lutech-quantum-cnn 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page