-
Notifications
You must be signed in to change notification settings - Fork 400
Closed
Labels
Description
This problem was brought up here https://qiskit.slack.com/archives/CB6C24TPB/p1631635618251500
The following should create a VQC instance with default feature map and ansatz.
from qiskit_machine_learning.algorithms.classifiers import VQC
vqc = VQC(num_qubits=4)
however it fails with
File qiskit_machine_learning\algorithms\classifiers\vqc.py", line 107, in __init__
self._circuit.compose(feature_map, inplace=True)
File qiskit\circuit\quantumcircuit.py", line 727, in compose
qubits = list(range(other.num_qubits))
AttributeError: 'NoneType' object has no attribute 'num_qubits'
It seems to be from this logic https://github.com/Qiskit/qiskit-machine-learning/blob/673140c0624ad928ec1b6da307e58221847c48da/qiskit_machine_learning/algorithms/classifiers/vqc.py#L106-L108
where the latter tries to compose feature_map and ansatz, which are directly the params from init. I think more likely it should be using self.feature_map and self.ansatz to pull in whatever these ended up as, whether supplied or internally created.
Needs some unit tests to cover the various paths whether defaulted or not.