TransWikia.com

Type object 'AllPairs' has no attribute 'params'

Quantum Computing Asked by Shubham Agnihotri on August 25, 2020

When I try QSVM over Iris data, it needs multiclass extension, but when I provide it, a following error is returned:

AttributeError                            Traceback (most recent call last)
<ipython-input-18-86cd4e7dd846> in <module>
      2 
      3 feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement='linear')
----> 4 qsvm = QSVM(feature_map, training_input, test_input, multiclass_extension=AllPairs)

d:anacondaenvsailibsite-packagesqiskitaquaalgorithmsclassifiersqsvmqsvm.py in __init__(self, feature_map, training_dataset, test_dataset, datapoints, multiclass_extension, quantum_instance)
    148         else:
    149             multiclass_extension.set_estimator(_QSVM_Estimator, [feature_map])
--> 150             qsvm_instance = _QSVM_Multiclass(self, multiclass_extension)
    151 
    152         self.instance = qsvm_instance

d:anacondaenvsailibsite-packagesqiskitaquaalgorithmsclassifiersqsvm_qsvm_multiclass.py in __init__(self, qalgo, multiclass_classifier)
     37         super().__init__(qalgo)
     38         self.multiclass_classifier = multiclass_classifier
---> 39         self.multiclass_classifier.params.append(qalgo)
     40 
     41     def train(self, data, labels):

AttributeError: type object 'AllPairs' has no attribute 'params'

The code is :

seed = 10598

feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement='linear')
qsvm = QSVM(feature_map, training_input, test_input, multiclass_extension=AllPairs)
```

One Answer

The multiclass code was refactored a little some while ago. Here is a tutorial showing the use of these classifiers with QSVM that works with how things are now that should help https://github.com/qiskit-community/qiskit-community-tutorials/blob/master/machine_learning/qsvm_multiclass.ipynb

You will see you now pass an instance of the multiclass in and no longer have that other setup around the multiclass extension and the algorithm.

Answered by Steve Wood on August 25, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP