Possible to create a QNN like classical one?

Hi @SuFong_Chien,

In view of this, I move to the “Fraud detection fitting script”

Just to check, do you mean this script?

Is the output layer of the classical net that set to 14 is because of the paper just takes half of the data features to study?

Looking back at the paper, I recall we took the first ten principal components from the credit card data as the input features. We then had a series of classical layers with the final layer having 14 features. The justification for this was that there are 14 free parameters in the first layer of a 2-mode CV layer.

The paper does not state why it chooses 4 points to U gate, 2 for each S gate, 2 for each Dgate, and 1 for each K gate? Is it an arbitrary choice?

Good question! We chose these numbers to match the free parameters of each gate. For squeezing (Sgate) and displacement (Dgate) the input can be thought of as complex, and so there is both a magnitude and angle input. The interferometer is broken down into a beamspliter (BSgate) and a rotation gate (Rgate) on each mode. The beamsplitter has two angle parameters, while each Rgate has a single parameter, summing to 4. Finally, the Kerr gate is simply described by a single parameter. You could check out here for some more context on the number of parameters.

If I set 8 output neurons, can I simply put 2 for U, 1 for S,D,K each?

Yes, this should be possible. Overall there are 14 gate parameters. If we only control 8 and assume the rest are zero or fixed, we may expect the layer to be less flexible and for training to hence take longer or maybe fail.

This example chooses the same number of neurons for the input layer and both hidden layers in claasical net, is it free to choose different type for this particular case?

Yes, there is also freedom here. The choice of [10, 10, 14] was arbitrary, except for the 14 which was motivated as discussed above. You could do [8, 8, 14] and things may work just as well. This is a familiar machine learning question about how to design the network.

This example has two final outputs in qnn for classication, it is either zero or one. However, my work needs to get 4 real outputs, how to modifiy the so-called “one_hot_input”? I think I may need phi = a1*[1,0,0,0]+ a2*[0,1,0,0]+ a3*[0,0,1,0]+ a4*[0,0,0,1]. Can you show the way?

If we stick with two modes, you could associate the probability of two photons in either mode as the remaining two classes. For example:
(# photons in mode 1, # photons in mode 2)
(0, 1): class 1
(1, 0): class 2
(0, 2): class 3
(2, 0): class 4
Practically this could be achieved by updating the one_hot_input around line 286.