Skip to content

Commit

Permalink
Merge pull request #861 from qiboteam/cmaebounds
Browse files Browse the repository at this point in the history
update bounds keyword docs for CMAES
  • Loading branch information
scarrazza authored Apr 25, 2023
2 parents 87ed54f + 2eb6a61 commit 864f4aa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/qibo/optimizers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from qibo.config import log, raise_error


def optimize(
loss,
initial_parameters,
Expand Down Expand Up @@ -76,6 +79,11 @@ def myloss(parameters, circuit):
circuit.set_parameters(params)
"""
if method == "cma":
if bounds is not None: # pragma: no cover
raise_error(
RuntimeError,
"The keyword 'bounds' cannot be used with the cma optimizer. Please use 'options' instead as defined by the cma documentation: ex. options['bounds'] = [0.0, 1.0].",
)
return cmaes(loss, initial_parameters, args, options)
elif method == "sgd":
if backend is None:
Expand Down Expand Up @@ -226,8 +234,6 @@ def sgd(loss, initial_parameters, args=(), options=None, compile=False, backend=
- ``'nmessage'`` (int, default: ``1e3``): Every how many epochs to print
a message of the loss function.
"""
from qibo.config import log, raise_error

if not backend.name == "tensorflow":
raise_error(RuntimeError, "SGD optimizer requires Tensorflow backend.")

Expand Down

0 comments on commit 864f4aa

Please sign in to comment.