I’m trying to adapt the VQT tutorial code to 2 qubits. I changed the number of qubits, obviously, and the circuit. However, my cost function is returning two values. How to fix this? Is my circuit inadequate? How to change the coupling? Should I change another part besides the circuit?
Here is the circuit:
ev = qml.device("lightning.qubit", wires=nr_qubits)
def quantum_circuit(rotation_params, coupling_params, sample=None):
qml.BasisStatePreparation(sample, wires=range(nr_qubits))
for i in range(len(rotation_params)):
qml.RX(rotation_params[i][0], wires=0)
qml.RX(rotation_params[i][1], wires=1)
qml.CRX(coupling_params[i][0], wires=[0, 1])
return qml.expval(qml.Hermitian(ham_matrix, wires=range(nr_qubits)))
qnode = qml.QNode(quantum_circuit, dev, interface="autograd")
rotation_params = [[[1, 1], [1, 1], [1, 1]] for i in range(0, depth)]
coupling_params = [[1] for i in range(0, depth)]
print(qml.draw(qnode, expansion_strategy="device", show_matrices=True)(rotation_params, coupling_params, sample=[1, 0]))