DQCPError:问题不是 DQCP。在 IBM Quantum Experience 中实施 QSVM 时
我试图在 IBM QE 中执行以下代码(实现基于 QSVM 的分类器)
feature_dim = 2 feature_map = ZZFeatureMap(feature_dimension=feature_dim, 代表=2, 纠缠='线性') qsvm = QSVM(feature_map,training_input,test_input)
backend = BasicAer.get_backend('qasm_simulator') Quantum_instance = QuantumInstance(backend,shots=1024,seed_simulator=seed,seed_transpiler=seed)
result = qsvm.run(quantum_instance)
print(f'测试成功率: {result["testing_accuracy"]}')
我收到以下错误:
回溯(最近一次调用最后一次): 在<细胞系:8>中输入[18] 结果 = qsvm.run(quantum_instance) 文件 /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/quantum_algorithm.py:71 运行中 返回 self._run() _run 中的文件 /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/qsvm.py:476 返回 self.instance.run() 文件 /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py:135 运行中 self.train(self._qalgo.training_dataset[0], self._qalgo.training_dataset[1]) 文件 /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py:82 火车中 [alpha,b,支持] = optimize_svm(kernel_matrix,标签,缩放=缩放,lambda2=lambda2) Optimize_svm 中的文件 /opt/conda/lib/python3.8/site-packages/qiskit/aqua/utils/qp_solver.py:93 prob.solve(verbose=show_progress, qcp=True) 解决文件/opt/conda/lib/python3.8/site-packages/cvxpy/problems/problem.py:473 返回solve_func(self, *args, **kwargs) _solve 中的文件 /opt/conda/lib/python3.8/site-packages/cvxpy/problems/problem.py:945 引发错误。DQCPError(“问题不是 DQCP。”) DQCPError:问题不是 DQCP。
使用 %tb 获取完整的回溯。
这是因为像 aqua 一样已弃用的软件包,而且 QSVM 上的 qiskit 教程(二进制和多分类器)也丢失了。有人可以帮我吗? 非常感谢
I was trying to execute the following code in IBM QE (implementing a QSVM based classifier)
feature_dim = 2
feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement='linear')
qsvm = QSVM(feature_map, training_input, test_input)
backend = BasicAer.get_backend('qasm_simulator')
quantum_instance = QuantumInstance(backend, shots=1024, seed_simulator=seed, seed_transpiler=seed)
result = qsvm.run(quantum_instance)
print(f'Testing success ratio: {result["testing_accuracy"]}')
I get the following error :
Traceback (most recent call last):
Input In [18] in <cell line: 8>
result = qsvm.run(quantum_instance)
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/quantum_algorithm.py:71 in run
return self._run()
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/qsvm.py:476 in _run
return self.instance.run()
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py:135 in run
self.train(self._qalgo.training_dataset[0], self._qalgo.training_dataset[1])
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py:82 in train
[alpha, b, support] = optimize_svm(kernel_matrix, labels, scaling=scaling, lambda2=lambda2)
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/utils/qp_solver.py:93 in optimize_svm
prob.solve(verbose=show_progress, qcp=True)
File /opt/conda/lib/python3.8/site-packages/cvxpy/problems/problem.py:473 in solve
return solve_func(self, *args, **kwargs)
File /opt/conda/lib/python3.8/site-packages/cvxpy/problems/problem.py:945 in _solve
raise error.DQCPError("The problem is not DQCP.")
DQCPError: The problem is not DQCP.
Use %tb to get the full traceback.
Is this because of deprecated packages like in the case of aqua, also the qiskit tutorials on QSVMs (both binary and multi-classifier ) are missing. Could someone help me out ?
Much thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如您所见,Qiskit Aqua 已被弃用,并且不再受支持。
我建议查看 Qiskit 机器学习中的等效函数,其中来自 Aqua 的所有 ML 相关函数都被移动/重构。这里有一个教程显示基于内核的算法 https://qiskit.org/documentation /machine-learning/tutorials/03_quantum_kernel.html 这里,QSVM 现在称为 QSVC,并扩展了 sklearn SVC。
Qiskit Aqua was deprecated, as you have seen, and is no longer supported.
I would suggest looking at the equivalent function in Qiskit Machine Learning where all the ML related function from Aqua was moved/refactored. There is a tutorial here showing kernel based algorithms https://qiskit.org/documentation/machine-learning/tutorials/03_quantum_kernel.html Here the QSVM is now called QSVC and extends sklearn SVC.