Hi @glassnotes,
I updated the code in the post above post above.
It should work now out of the box. If not, check out my repo at github: https://github.com/dymat/TrainableQuanvolution
Best regards,
~dymat
Hi @glassnotes,
I updated the code in the post above post above.
It should work now out of the box. If not, check out my repo at github: https://github.com/dymat/TrainableQuanvolution
Best regards,
~dymat
@dymat thank you for posting the code I will try to run it and get back to you asap
Thanks @dymat, it’s very cool that you had some positive results training on MNIST (at least for the 1 quantum layer). If you’re interested, I think this would make a great demo! We have just launched a community space for demos. Since you already have a Jupyter Notebook, is should just be a case of creating an issue here (see instructions).
On to your question about the gradient for two layers, I had a quick look and unfortunately nothing jumped out as a problem. I might have a chance to dig a bit deeper next week, however for now I would suggest some debugging. For example, what if we swapped out the quantum circuit (self.circuit
) with a simple torch function? If you still aren’t getting a gradient in the first layer, it’s probably an issue with the big for
loop in forward()
. Otherwise, we can look at if it’s an issue on the PL side.
Hope this helps a bit!
Tom
@dymat went through your code and ran it a few times with some changes. I haven’t found the source of the gradient problem yet. But will still keep looking and update if i find something!
Hi @Tom_Bromley,
publishing our notebook as a demo sounds cool. I would use the one-layer example. Can we change the demo notebook later on, if we find the source of the gradient problem in two-layer networks?
Best regards,
D
Ok, I’ve checked the instructions and see that my question is obsolete, since the code lives in my repo.
Hi @dymat, awesome, we’re looking forward to seeing your demo! Let us know if you have any further questions while getting it ready.
Hi @glassnotes, the demo request is submitted (https://github.com/PennyLaneAI/qml/issues/165).
Best regards,
D
Hi @dymat @Tom_Bromley , has this issue of quantum layer 0 not getting any gradients been solved? Any update?
Hi @gojiita_ku, thank you for your question and sorry for the delay in responding!
I haven’t seen gradient issues recently. Are you experiencing a similar issue?
If so, please share with us a minimal version of your code, the output of qml.about()
, and your full error traceback.
If you run our quanvolutional neural networks demo as-is, does it work properly?
I’ll be looking out for your answer!
Hi @Tom_Bromley and @CatalinaAlbornoz,
Could you please give a code example in this case about how to swap out the quantum circuit (self.circuit
) with a simple torch function as suggested by Tom?
For example, what if we swapped out the quantum circuit (
self.circuit
) with a simple torch function ?
Many thanks!
Hi @CatalinaAlbornoz. I run this notebook and found parameters in both of two QonvLayers were updated successfully every epoch. But if I change the code a little bit (e.g. build the model using nn.Module
instead of nn.Sequential
), I found parameters in the first QonvLayer were not updated. I don’t know the reason. I’ve uploaded my notebook file. Could you please take a look if you have free time? Many thanks!
StackedQuanvolutions.py (5.3 KB)
Here is the output of qml.about()
:
Name: PennyLane
Version: 0.28.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /Users/chenyixiong/opt/anaconda3/lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-qiskit, pennylane-qulacs
Platform info: macOS-10.16-x86_64-i386-64bit
Python version: 3.9.13
Numpy version: 1.21.5
Scipy version: 1.9.1
Installed devices:
- lightning.qubit (PennyLane-Lightning-0.28.2)
- qiskit.aer (PennyLane-qiskit-0.28.0)
- qiskit.basicaer (PennyLane-qiskit-0.28.0)
- qiskit.ibmq (PennyLane-qiskit-0.28.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.28.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.28.0)
- qulacs.simulator (pennylane-qulacs-0.28.0)
- default.gaussian (PennyLane-0.28.0)
- default.mixed (PennyLane-0.28.0)
- default.qubit (PennyLane-0.28.0)
- default.qubit.autograd (PennyLane-0.28.0)
- default.qubit.jax (PennyLane-0.28.0)
- default.qubit.tf (PennyLane-0.28.0)
- default.qubit.torch (PennyLane-0.28.0)
- default.qutrit (PennyLane-0.28.0)
- null.qubit (PennyLane-0.28.0)
Hi @gojiita_ku,
I’m really sorry I somehow didn’t see your question when you asked it. Are you still having the same problem? Do you still need our help?