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

Problem with running example: "2. Interactive bayesian optimisation" #1

Closed
Kendall-P-Taylor opened this issue Dec 4, 2020 · 1 comment

Comments

@Kendall-P-Taylor
Copy link

Thanks very much for publishing GPro. I've been struggling with my own implementation of Chu and Ghahramani's work and I'm very grateful to be able to use your work. However, when running your example: "2. Interactive bayesian optimization." I have unfortunately encountered a problem. I have included the error traceback below:

 File "...\venv\lib\site-packages\GPro\preference.py", line 324, in bayesopt
    res = minimize(lambda x: -aqc_optim(x.reshape(1, -1),
  File "...\venv\lib\site-packages\scipy\optimize\_minimize.py", line 617, in minimize
    return _minimize_lbfgsb(fun, x0, args, jac, bounds,
  File "...\venv\lib\site-packages\scipy\optimize\lbfgsb.py", line 306, in _minimize_lbfgsb
    sf = _prepare_scalar_function(fun, x0, jac=jac, args=args, epsilon=eps,
  File "...\venv\lib\site-packages\scipy\optimize\optimize.py", line 261, in _prepare_scalar_function
    sf = ScalarFunction(fun, x0, args, grad, hess,
  File "...\venv\lib\site-packages\scipy\optimize\_differentiable_functions.py", line 95, in __init__
    self._update_grad()
  File "...\venv\lib\site-packages\scipy\optimize\_differentiable_functions.py", line 171, in _update_grad
    self._update_grad_impl()
  File "...\venv\lib\site-packages\scipy\optimize\_differentiable_functions.py", line 91, in update_grad
    self.g = approx_derivative(fun_wrapped, self.x, f0=self.f,
  File "...\venv\lib\site-packages\scipy\optimize\_numdiff.py", line 388, in approx_derivative
    raise ValueError("`f0` passed has more than 1 dimension.")
ValueError: `f0` passed has more than 1 dimension.

I've managed to get the example working by flattening the returned array from the acq_optim function on line 311 of the file preference.py. Do you think this is an appropriate solution to my error or does the problem lie elsewhere?
(By the way, I have implemented the code exactly as you have it in the example).

@chariff
Copy link
Owner

chariff commented Jan 2, 2021

Hello sir, sorry for the late reply. The issue you raised has to do with the scipy minimize objective function output not being a 1-D array but rather a 2-D array of shape (1, 2). In scipy versions < 1.4 the aforementioned output is indeed sqeezed to a 1-D array. I updated the code to enable scipy versions > 1.4. Thank you for raising this issue.

@chariff chariff closed this as completed Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants