i want to design a swap classifier using amplitude encoding method Pennylane. But i got this error:
pennylane._device.DeviceError: Operation QubitStateVector cannot be used after other Operations have already been applied on a default.qubit.autograd device.
Tom explained to me before about the source of issue About amplitude embedding. Here is my code:
@qml.qnode(dev)
def swap_test(x1, x2):
# load the two inputs into two different registers
qml.templates.embeddings.AmplitudeEmbedding(x1, wires=[1, 2, 3, 4, 5])
qml.templates.embeddings.AmplitudeEmbedding(x2, wires=[6, 7, 8, 9, 10])
qml.Hadamard(wires=0)
qml.CSWAP(wires=[0, 1, 6])
qml.CSWAP(wires=[0, 2, 7])
qml.CSWAP(wires=[0, 3, 8])
qml.CSWAP(wires=[0, 4, 9])
qml.CSWAP(wires=[0, 5, 10])
qml.Hadamard(wires=0)
return qml.expval(qml.PauliZ(0))
as you can see the second qml.templates.embeddings.AmplitudeEmbedding(x2, wires=[6, 7, 8, 9, 10])
is at the first of circuit. It should work without error. But it did’t. Do you know how i can solve this problem.