Quantum photonic convolutional neural network

Anybody tried or have the example code on quantum photonic convolution neural network using PennyLane with Strawberry Fields. I tried the example given in the website using the ‘default.qubit’. I tried with ‘default.gaussian’, but I could not configure the equivalent logic similar to the ‘default.qubit’ basis. I want to completely run the convolutional neural network using quantum photonics. Please help in this regard. Thanks in advance…

Hi @Mubarak! Thanks for sharing your experience. Is this the tutorial you’re referring to?

Would you be able to provide an example of where your code is failing? This will help us to understand your problem :slight_smile:

In this work, just I have replaced the ‘default.qubits’ with ‘default.gaussian’ and changed the qml.RY with qml.Rgate


I dont know how to invoke the pennylane-sf plugin for quantum photonic processing. The same example I have to work out with quantum photonic operations. So, help needed in this regard. Thanks in advance…

Hi @Mubarak, thanks for sharing your code!

The specific error you are encountering will be solved by:

import strawberryfields as sf

sf.ops.Rgate(np.pi * phi[j])

However, there will be several other changes needed. Since you are changing the qubit device to a CV qumode device you will need to change each qubit operator to an analogous CV operation.

You might find this demo to be a useful guide as it combines qubit and CV operations.

Let us know if you have any more questions :slight_smile:

Thank you for your response @Ant_Hayes.

I will follow your instructions, check, and update you…

Happy to help :slight_smile: let us know if you have any more questions!

I have tried the example with ‘default.gaussian’ device. I have replaced the ‘qm.RY’ operation with
sf.ops.Rgate(np

.pi * phi[j]) and qml.Rotation(np.pi * phi[j]), I can get results without the Randomlayers. If I include the randomlayers again it shows an error message as below,

DeviceError: Gate RX not supported on device default.gaussian

Hi @Mubarak, glad to see your making progress here :smiley:

The RandomLayers class can be thought of as a template circuit containing randomly chosen entangling gates acting on randomly chosen qubits.

Since your aim is to perform a Q-CNN with CV states and operations this random circuit will need to consist of CV operations. Since this circuit can be random it would be great to try diffferent arrangements of CV operations and see which works best!

Let us now if you have any more questions and we’ll be happy to help!

I try to include the CVNeuralNetLayers, as am using ‘default.gaussian’, the Kerr operation inside the CVNeuralNetLayers shows an error like “DeviceError: Gate Kerr not supported on device default.gaussian”
Moreover, I want to utilize the CubicPhase instead of Kerr gate. How to change the CVNeuralNetLayers to work with CubicPhase gate for nonlinear activation function.

I feel the document support for ‘gaussian’ based operations is limited compared to the document support for ‘qubit’ and ‘fock’ based operations.

Pls help in this regard. Thanks in advance…

Hi @Mubarak,

This behaviour is to be expected as the default.guassian device doesn’t support non-Guassian operations such as the Kerr gate or CubicPhase gate.

To use these operations you can use the strawberryfields.fock device which supports both Guassian and non-Gaussian operations. Note that this uses the PennyLane-Strawberry Fields plugin which you may need to install if you haven’t done so already.

You might also find this demo on quantum optical neural networks to have some useful examples similar to what you are doing here.

Let us know how it goes and if you have any further questions!

1 Like