Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update bounds keyword docs for CMAES #861

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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