diff --git a/src/qiboml/models/ansatze.py b/src/qiboml/models/ansatze.py index 137fa3b..ce10249 100644 --- a/src/qiboml/models/ansatze.py +++ b/src/qiboml/models/ansatze.py @@ -4,15 +4,20 @@ from qibo import Circuit, gates -def ReuploadingCircuit(nqubits: int, qubits: list[int] = None) -> Circuit: +def ReuploadingCircuit( + nqubits: int, qubits: list[int] = None, nlayers: int = 1 +) -> Circuit: if qubits is None: qubits = list(range(nqubits)) circuit = Circuit(nqubits) - for q in qubits: - circuit.add(gates.RY(q, theta=random.random() * np.pi, trainable=True)) - circuit.add(gates.RZ(q, theta=random.random() * np.pi, trainable=True)) - for i, q in enumerate(qubits[:-2]): - circuit.add(gates.CNOT(q0=q, q1=qubits[i + 1])) - circuit.add(gates.CNOT(q0=qubits[-1], q1=qubits[0])) + + for _ in range(nlayers): + for q in qubits: + circuit.add(gates.RY(q, theta=random.random() * np.pi, trainable=True)) + circuit.add(gates.RZ(q, theta=random.random() * np.pi, trainable=True)) + for i, q in enumerate(qubits[:-2]): + circuit.add(gates.CNOT(q0=q, q1=qubits[i + 1])) + circuit.add(gates.CNOT(q0=qubits[-1], q1=qubits[0])) + return circuit