TypeError: unsupported operand type(s) for +=: 'QuantumCircuit' and 'QuantumCircuit'

176 views Asked by At

I try to train my model using Quantum CNN by qiskit I got error in this code line

backend = qiskit.Aer.get_backend('qasm_simulator')
filter_size = 2
circ = QuanvCircuit(filter_size, backend, 100, 127)

the error is

TypeError                                 Traceback (most recent call last)

<ipython-input-18-c2f77b5d5f07> in <cell line: 3>()
      1 backend = qiskit.Aer.get_backend('qasm_simulator')
      2 filter_size = 2
----> 3 circ = QuanvCircuit(filter_size, backend, 100, 127)
      4 data = torch.tensor([[0, 200], [100, 255]])
      5 

<ipython-input-11-b404662ad0ce> in __init__(self, kernel_size, backend, shots, threshold)
     14 
     15         self._circuit.barrier()
---> 16         self._circuit += random_circuit(self.n_qubits, 2)
     17         self._circuit.measure_all()
     18         # ---- Circuit definition end ----

TypeError: unsupported operand type(s) for +=: 'QuantumCircuit' and 'QuantumCircuit'

How to fix it?

1

There are 1 answers

0
Steve Wood On

See Combining quantum circuits in Qiskit for an answer (which is + and += were deprecated and removed and there is more info on what to do instead)