1
$\begingroup$

I want to find the estimate of the ground state energy of my Hamiltonian H that is implemented as PauliSumOp in my variable H_op. I then prepare an ansatz circuit circ_ansatz with 5 parameters. Then I try to run the thing with my_vqe = VQE(ansatz = circ_ansatz, optimizer=SPSA, quantum_instance=Aer.get_backend('aer_simulator'), initial_point=[0.5]*N_iters) and then print(my_vqe.compute_minimum_eigenvalue(H_op)) but I get the following error: print(my_vqe.compute_minimum_eigenvalue(H_op)) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qiskit/algorithms/minimum_eigen_solvers/vqe.py", line 526, in compute_minimum_eigenvalue opt_result = self.optimizer( # pylint: disable=not-callable TypeError: __init__() got an unexpected keyword argument 'fun'

Any help is highly appreciated!

$\endgroup$

1 Answer 1

2
$\begingroup$

my_vqe = VQE(ansatz = circ_ansatz, optimizer=SPSA,...

You need to make an instance of the optimizer not pass the class (set any parameters you want the following uses defaults)

my_vqe = VQE(ansatz = circ_ansatz, optimizer=SPSA(),...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.