1
$\begingroup$

I have imported ADAM optimizer in the following way:

from qiskit.algorithms.optimizers import COBYLA, ADAM, SPSA, SLSQP, POWELL, L_BFGS_B, TNC, AQGD

Afterwards, I declare optimizer = ADAM(maxiter=100), however when I write optimizer.optimize it gives me the error that ADAM object has not attribute optimize. I have checked the Qiskit documentation and I believe the method is correct.

Can someone help?

$\endgroup$

1 Answer 1

0
$\begingroup$

The optimize method was deprecated some 3 years ago to be replaced by minimize

Deprecate Optimizer.optimize in favor of Optimizer.minimize to use a signature closer to SciPy's minimize and move towards using plain callables in variational algorithms

  • all our optimizers minimize, reflect that in the name

This is the latest documentation for ADAM and this is minimize() there. Please note that algorithms were moved out of Qiskit into a separate repository some time ago. They no longer exist in the most recent 1.0 version of Qiskit. For you to be seeing optimize in documentation you must be looking at some pretty old content somewhere.

For the latest algorithms, including the optimizers, you would pip install qiskit_algorithms and then instead of

from qiskit.algorithms.optimizers import COBYLA

do

from qiskit_algorithms.optimizers import COBYLA

where you simply replace the . between qiskit and algorithms with an _ (underscore)

$\endgroup$

Your Answer

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

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