Translate the fraud detector in Strawberry fields to PennyLane

Hi there, I am traying to translate the code in this link https://github.com/XanaduAI/quantum-neural-networks/blob/master/fraud_detection/fraud_detection.py written with Strawberry Fields to Pennylane.

Is there any way to do it following the tutorials in the PennyLane site?

Hi @abignu, this sounds like a nice task and also shouldn’t be too hard to do.

The best tutorial to follow in PennyLane is this one: https://pennylane.ai/qml/app/quantum_neural_net.html
This tutorial constructs a single mode photonic quantum neural network. You’d need to extend this to the two mode QNN used in the fraud detection model.

As the fraud detection model is a hybrid, you can use the TensorFlow interface when defining your qnode: https://pennylane.readthedocs.io/en/stable/introduction/interfaces/tf.html.

One thing to be aware of is that the fraud detection code is designed for TensorFlow version 1.3 but the TF interface in PennyLane requires a newer TF version of at least 1.12.

Let me know how it goes and I’ll be happy to help if you get stuck!
Thanks
Tom

Hi @Tom_Bromley thanks for the quick reply. I will check the links you have passed me. If I have any issue I will let you know.

Thanks in advance

@abignu, did you succeed with your implementation?

We have tried implementing it using a Numpy interface. @Tom_Bromley, there seems to be some issues with using autograd and the Strawberry fields back end. Shouldn’t it be possible to implement Fraud Detection without using Tensorflow?

Hi @slowBison, what issue were you running into?

Hi Josh! Sorry for the late reply.
The problem was that the gates weren’t too happy about the autograd arrays it received as input.

We have rewritten the code, so it now runs. The cost function converges, albeit very very slowly.

@slowBison,

We have been working a lot lately on speeding up the underlying operations in Strawberry Fields as much as possible. I am cautiously optimistic that by the next results you should hopefully see some nice speedups versus previous versions.

1 Like