Hi @GONUL_SABAH,
You’re right.
First, classical features should be embedded in qubits state.
Common Data emmbedding schemes such as angle embedding and basis embedding require N qubits to embedd N features.
For instance, if N is 5,
# classical data , x , has 5 features.
# Angle-embedding by qml.RX
qml.RX(x[0],wires=0)
qml.RX(x[1],wires=1)
qml.RX(x[2],wires=2)
qml.RX(x[3],wires=3)
qml.RX(x[4],wires=4)
Note: another approach of data emmbedding is amplitude encoding in which only log2(N) qubits are required to embedd N features.
However, amplitude encoding requires huge gate counts.
Then, the states are scrambled by parameterized gates.
qml.Rot(W[0, 0], W[0, 1], W[0, 2], wires=0)
qml.Rot(W[1, 0], W[1, 1], W[1, 2], wires=1)
qml.Rot(W[2, 0], W[2, 1], W[2, 2], wires=2)
qml.Rot(W[3, 0], W[3, 1], W[3, 2], wires=3)
qml.Rot(W[4, 0], W[4, 1], W[4, 2], wires=4)
qml.CNOT(wires=[0, 1])
qml.CNOT(wires=[1, 2])
qml.CNOT(wires=[2, 3])
qml.CNOT(wires=[3, 4])
qml.CNOT(wires=[4, 0])
Ofcourse, you also can truncate some paramterized gates although the expressivity will drop.
qml.Rot(W[0, 0], W[0, 1], W[0, 2], wires=0)
qml.Rot(W[1, 0], W[1, 1], W[1, 2], wires=2)
qml.Rot(W[2, 0], W[2, 1], W[2, 2], wires=4)
qml.CNOT(wires=[0, 1])
qml.CNOT(wires=[2, 3])
qml.CNOT(wires=[4, 0])
Moreover, “repeat” is welcome to enhance the expressivity.
# two variational layers!
# 1st
qml.Rot(W[0, 0], W[0, 1], W[0, 2], wires=0)
qml.Rot(W[1, 0], W[1, 1], W[1, 2], wires=1)
qml.Rot(W[2, 0], W[2, 1], W[2, 2], wires=2)
qml.Rot(W[3, 0], W[3, 1], W[3, 2], wires=3)
qml.Rot(W[4, 0], W[4, 1], W[4, 2], wires=4)
qml.CNOT(wires=[0, 1])
qml.CNOT(wires=[1, 2])
qml.CNOT(wires=[2, 3])
qml.CNOT(wires=[3, 4])
qml.CNOT(wires=[4, 0])
# 2nd
qml.Rot(W[5, 0], W[5, 1], W[5, 2], wires=0)
qml.Rot(W[6, 0], W[6, 1], W[6, 2], wires=1)
qml.Rot(W[7, 0], W[7, 1], W[7, 2], wires=2)
qml.Rot(W[8, 0], W[8, 1], W[8, 2], wires=3)
qml.Rot(W[9, 0], W[9, 1], W[9, 2], wires=4)
qml.CNOT(wires=[0, 1])
qml.CNOT(wires=[1, 2])
qml.CNOT(wires=[2, 3])
qml.CNOT(wires=[3, 4])
qml.CNOT(wires=[4, 0])
Finally, measurement should be performed.
In binary-classifier, the output should be a scaler value.
Therefore, one of 5 qubits is measured.
return qml.expval(qml.PauliZ(0))
Ofcourse, the position of qubits can be changed if you want.
return qml.expval(qml.PauliZ(1))
After the measurement, paramterized gates , W, will be updated so that cost (=classification error) is minimized.
Please let me know if you have questions.