QNN feature extractor

Regarding :GitHub - hritiksauw199/Quantum-vs-Classical-Brain-Tumor-Classification: Classified brain tumor using a Hybrid Quantum-Classical Neural Network and compared it against a classical model (DenseNet121)

He make feature extractor based on FIXED quantum circuit, he make no training of the PQC parameters, like done in classical CNN. What is the use of this if feature extractor can not study images? It would be like taking a randomly initialize CNN from pytorch …

Hello @wing_chen! It seems that this person is reproducing this paper https://arxiv.org/pdf/2009.09423.pdf As you can see, there is training of the PQC parameters, in particular the rotation angles of the RX gates. Hope this helps!

Interesting … I may be wrong but I tend to agree with @wing_chen. The original paper trained the PQC parameters by initialising the unitaries to random values, and then learning them via gradient descent. Here on the other side, in his training and optimisation loop there is learning only for the FC layer, not for the quantum circuit. It is true that the quantum circuit has learnable RX gates, but in the code that is used to extract features from the images, no learning or optimisation (Adam/SGD) is conducted for them - it is just a simple loop:

Thank you for your input @Solomon! That does see to be the case :thinking: At this point, I think it might be better to contact the owner of the repo, rather than us speaking for them!

If you want to learn more about the topic, this PennyLane tutorial might help!


In link you gave: Quanvolutional Neural Networks — PennyLane documentation

“Since we are not going to train the quantum convolution layer, it is more efficient to apply it as a “pre-processing” layer to all the images of our dataset. Later an entirely classical model will be directly trained”
So even in PennyLane original code, the quantum network does not really do anything … never optimized. Just like using an image augmentation. The learning process is ONLY on the FC layer. So I ask wahat is the point?

Hi @wing_chen,

The quantum circuit acts as a convolution kernel so indeed it’s only used for pre-processing. In the description at the top of the demo, in bullet point 2, it reads that you can change the random circuit for a variational circuit. For simplicity they used a random circuit but a project that you could try is seeing if changing this to a variational circuit would change something in the results.

I cannot answer for the authors’ motivations for how they designed their algorithm, but something important to remember is that the question isn’t always about doing something better than classical. A very valid research question is asking yourself “what will change if I add a quantum circuit here?” The answer may be that it works worse, but the question is still valid and valuable.

On this topic I encourage you to read the blog post Why measuring performance is our biggest blind spot in quantum machine learning, by Maria Schuld.

Let me know if you have any further questions.