1
$\begingroup$

I am referring to the tutorial of CV-QNN in Pennylane(Strawberry Fields). Each layer of CV-QNN can perform the operation below.

enter image description here

Unlike other quantum neural network tutorials, where the input X and y are given explicitly, this is not the case here. However, they have mentioned Encoding data outside of the position eigenbasis, for example using instead the Fock basis. How can I encode my data which is in the format of X and y, where each sample is a 6-dimensional vector and y is a real value in [0,1]? I have X as a pandas data frame of shape [150,6] and y is a pandas series of length 150. How to train the CV Neural Network using my data?

$\endgroup$

1 Answer 1

0
$\begingroup$

For quantum neural networks, it is preferable to have two additional layers (optionally) besides the VQC (Variational Quantum Circuit) layers which perform your transformations. These are namely the -

  • Encoding Layer: Here, one uses a particular encoding scheme to encode the data in a quantum state. A particular choice in CV QNNs is to apply a displacement gate parameterized by the value you wish to encode on the vacuum state. In other words, $D(x)| 0 \rangle = | x \rangle$. If you have a vector of values that you wish to encode, you would have to use a vector of vacuum states. In other words, one would need $\forall i \in [n]: D(x_i)|0\rangle = |x\rangle_i$. If your dataset is of the form $(x, y) \in \mathbb{R}^2$, it is also possible to cast it into a complex $z = x+iy$ and apply $D(z)$. As you can see, the schemes to encode the data via displacement would vary depending on the structure of your dataset and the shape of the output passed to the VQC layers would depend on your scheme.
  • Decoding Layer: Here, one essentially calculates expectation values of what you wish to observe, typically the $x-$quadtratures for the resulting batch of states you get from your VQC layers. These expectations are the outputs you require your Neural Network to optimize over to determine the parameters for the NN. To mimic a physical quantum system, one may also perform the decoding by performing a batch of measurements and averaging over them. The final outputs of this layer, supposing you are attempting to perform a fit, must have the same shape as your inputs. But of course, this can be different depending on the exact nature of your task.

However, note that I mentioned these layers to be optional. These are necessary when you wish to use a quantum neural network for cases where the I/O datasets are not quantum states themselves. Keep in mind that these layers do not contain any trainable parameters and are only to be present once at the beginning (encoding) of the network and at the end (decoding) without repetition. The repeated layers are only the VQC layers. While this is surely possible on platforms such as strawberry fields and pennylane, it may be better to design what is being done from scratch using Deep Learning and Neural Network libraries available on Python or Julia.

PS: The displacement encoding creates a coherent state and not a quadrature eigenstate, which is a superposition of all the fock states. However, the cutoff dimension you impose truncates this sum, which is a good approximation for an appropriately chosen cutoff. Thus you are in fact, encoding your data in a truncated fock basis.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.