Quantum convolution neural network using Keras

Hi @isaacdevlugt ! Thanks for the solution, it works ! Now I finally begin to train my model :laughing: :laughing:

One more quesiton regarding to training speed and simulator+diff_method. I notice that when using lightning.qubit as quantum circuit simulator, the speed of training one batch to compute loss with batch_size=5 using diff_method="adjoint" is much slower than using diff_method="parameter-shift". This is tested using 1 filter (1 quantum circuit).

  • lightning.qubit with "parameter-shift" : ~10.5s

  • lightning.qubit with "adjoint": ~43s

  • default.qubit with "backprop" : 17s

I fount this post explaning the possible reason, "parameter-shift" is faster when the number of qubit and training parameters are small, which is my quantum filter case, is this understanding right? Or something happen when combining lighting.qubit with tensorflow will slow down the "adjoint" method.

Also, I’m wondering when using diff_method='best', what diff_method will be use in my quantum circuit? I notice that after transforming to KerasLayer, the interface of the qnode will change to tf. What diff_method will be used if I using lightning.qubit now ? I reference to here, so my guess is it will backprop on lightning.qubit.tf.

I will be appreciated if you can tell me whether my understanding is right or not!

1 Like