Skip to content

Hamming weight preserving quantum convolutional neural network.

Notifications You must be signed in to change notification settings

anthonyrtw/quantum-cnn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hamming weight preserving quantum convolutional neural networks

In this notebook I attempt to reproduce results from Monbroussou et al titled Subspace preserving quantum convolutional neural network architectures. Here the authors propose a novel quantum convolutional neural network (QCNN) where each layer preserves the hamming weight distance of the model. i.e. the number of $|1\rangle$ states in the model statevector.

This allows for the QCNN to be efficiently trainable, escaping the problem of barren plateaus which is endemic to many quantum machine learning models.

Structure

├── data/ # Download the MNIST dataset here.
├── figures/ 
├── logs/
│   ├── 8x8 C(k=2, s=2)-P(k=2)-D-L T=0.015 batch_size=16 lr=0.001/
│   │   └── history.npz # Logged training, validation and loss curves.
│   │   └── qcnn_weights.pth # Optimized QCNN weights.
    ...
├── training_script.ipynb
├── training_script.py
├── src.py
├── requirements.txt
└── README.md

The logging of this project is notated by the structure of the QCNN and the hyperparameters used. For instance, consider the following directory: logs\8x8 C(k=2, s=2)-P(k=2)-PD-L T=0.015 batch_size=16 lr=0.001

QCNN Structure:

  • C(k=2, s=2): Convolution kernel size $= 2$, stride $= 2$.
  • P(k=2): Pooling kernel size $= 2$, stride $= 2$
  • PD: Pyramidal dense layer.
  • L: Classical linear layer

Hyperparameters:

  • T=0.015: 0.015 Softmax temperature.
  • batch_size=16: 16 batch size for training and evaluation.
  • lr=0.001: Learning rate $= 0.001$.

Requirements

This repository mostly relies on the Torch Quantum python package. Additionally the following python packages were used:

matplotlib==3.10.3
numpy==2.2.5
torch==2.5.1
torchquantum.egg==info
torchvision==0.20.1

Alternatively run the following command:

pip install requirements.txt

About

Hamming weight preserving quantum convolutional neural network.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published