acerbilab / pybads

PyBADS: Bayesian Adaptive Direct Search optimization algorithm for model fitting in Python
https://acerbilab.github.io/pybads/
BSD 3-Clause "New" or "Revised" License
69 stars 2 forks source link

Error converting shapes due to mismatched size of X and s2 #53

Open noraharhen opened 7 months ago

noraharhen commented 7 months ago

I'm getting this crazy error occasionally while running pybads with specify_target_noise=true. It looks like somehow s2 ends up with more elements than rows of X. Any idea what could be going on here?

Unfortunately, I cant create a reprex—it only happens occasionally with my own model fitting code...

Traceback (most recent call last):
  File "/dfs6/pub/nharhen/foraging/model_fitting/experiment1k_kids/cross_val/bads.py", line 39, in <module>
    result = bads.optimize()
  File "/data/homezvol3/nharhen/.local/lib/python3.9/site-packages/pybads/bads/bads.py", line 1239, in optimize
    ) = self._search_step_(gp)
  File "/data/homezvol3/nharhen/.local/lib/python3.9/site-packages/pybads/bads/bads.py", line 1554, in _search_step_
    gp, gp_exit_flag = local_gp_fitting(
  File "/data/homezvol3/nharhen/.local/lib/python3.9/site-packages/pybads/bads/gaussian_process_train.py", line 402, in local_gp_fitting
    gp, hyp_gp, res, exit_flag = _robust_gp_fit_(
  File "/data/homezvol3/nharhen/.local/lib/python3.9/site-packages/pybads/bads/gaussian_process_train.py", line 542, in _robust_gp_fit_
    new_hyp, _, res = tmp_gp.fit(
  File "/data/homezvol3/nharhen/.local/lib/python3.9/site-packages/gpyreg/gaussian_process.py", line 1008, in fit
    X, y, s2 = self._convert_shapes(X, y, s2)
  File "/data/homezvol3/nharhen/.local/lib/python3.9/site-packages/gpyreg/gaussian_process.py", line 2555, in _convert_shapes
    s2 = s2.reshape(N, 1)
ValueError: cannot reshape array of size 55 into shape (51,1)
lacerbi commented 6 months ago

Thanks for the report! This seems tough to debug if it happens randomly. @GurjeetSinghSangra is looking into it but this might take a while.

GurjeetSinghSangra commented 6 months ago

Hello @noraharhen, apologies for the late response, and thanks for reporting this.

I have been investigating this report. Unfortunately, by running Pybads on specified noisy tasks (specify_target_noise=true), I haven't been able to reproduce your problem, even for a high number of function evaluations (i.e. longer optimization runs) or high-dimension settings.

Moreover, by inspecting the most possible/likely parts of the code that should relate to your stack trace and related parts of the code. I do not find anything suspicious that could raise any errors or bugs.

I require a reproducible experiment to facilitate better debugging. The configuration setting should include your setting, which includes your function, prior bounds, and hopefully your random seed number.