From e1859ddbbe99734ac7dd56b05512e5a7420085aa Mon Sep 17 00:00:00 2001 From: "M. Emre Sahin" <40424147+OkuyanBoga@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:07:42 +0000 Subject: [PATCH] Added checks for different transpiler types (#879) --- qiskit_machine_learning/neural_networks/estimator_qnn.py | 5 ++++- qiskit_machine_learning/neural_networks/sampler_qnn.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qiskit_machine_learning/neural_networks/estimator_qnn.py b/qiskit_machine_learning/neural_networks/estimator_qnn.py index 9853ac645..99409afe1 100644 --- a/qiskit_machine_learning/neural_networks/estimator_qnn.py +++ b/qiskit_machine_learning/neural_networks/estimator_qnn.py @@ -182,7 +182,10 @@ def __init__( self.num_virtual_qubits = circuit.num_qubits else: circuit = pass_manager.run(circuit) - self.num_virtual_qubits = circuit.layout._input_qubit_count + if hasattr(circuit.layout, "_input_qubit_count"): + self.num_virtual_qubits = circuit.layout._input_qubit_count + else: + self.num_virtual_qubits = circuit.num_qubits self._org_circuit = circuit diff --git a/qiskit_machine_learning/neural_networks/sampler_qnn.py b/qiskit_machine_learning/neural_networks/sampler_qnn.py index b6a1eb911..ad2a17870 100644 --- a/qiskit_machine_learning/neural_networks/sampler_qnn.py +++ b/qiskit_machine_learning/neural_networks/sampler_qnn.py @@ -209,7 +209,10 @@ def __init__( self.num_virtual_qubits = circuit.num_qubits else: circuit = pass_manager.run(circuit) - self.num_virtual_qubits = circuit.layout._input_qubit_count + if hasattr(circuit.layout, "_input_qubit_count"): + self.num_virtual_qubits = circuit.layout._input_qubit_count + else: + self.num_virtual_qubits = circuit.num_qubits self._org_circuit = circuit