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

(Expected improvement not finite. Variance matrix may be singular) when num_to_sample > 1 #453

Open
rkrav opened this issue Feb 11, 2016 · 4 comments

Comments

@rkrav
Copy link

rkrav commented Feb 11, 2016

I'm posting the following JSON to gp/next_points/epi:
{"domain_info": {"dim": 1, "domain_bounds": [{"max": 1.0, "min": 0.0}]}, "gp_historical_info": {"points_sampled": [{"value_var": 0.01, "value": 0.1, "point": [0.0]}, {"value_var": 0.01, "value": 0.2, "point": [1.0]}]}, "num_to_sample": 2}
and it returns an error of

Expected improvement not finite. Variance matrix may be singular.

Is this expected behavior?

@suntzu86
Copy link
Contributor

I believe if you don't specify hyperparameters (starting to think we really should not have allowed users to do that), they all default to 1.0.

Your domain length is 1.0, so that means the GP predictor will look roughly like a straight line connecting the end points. When you try to find the best expected improvement for 2 simultaneous points, they'll both be out of bounds (and snapped back in bounds), which can cause the exact-EI computation to fail (when multiple points_to_sample are identical). They go out of bounds b/c the GP expects essentially 0 improvement from sampling inside the domain.

Setting the hyperparam length scale to say 0.1 should not have this issue.

But unless I'm missing something, that error comes from:

raise RuntimeError("Expected improvement not finite. Variance matrix may be singular.")

and should be handled here:

So I'm confused as to why it would be failing outright...

@rkrav
Copy link
Author

rkrav commented Feb 12, 2016

What does this hyperparameter mean here? By scale, do you mean theta in the prior covariance function? I thought that was fit from the data a la empirical bayes..

Does this mean that proper operating procedure is to first call gp_hyper_opt, retrieve the fitted hyperparameters, and then pass them to gp_next_points?

@suntzu86
Copy link
Contributor

like

cov(x,y) = \alpha * exp(\sum_i={1..d} [-0.5 * (x[i] - y[i])^2 / L[i]^2] )

the hyperparameters are [\alpha, L[0], L[1], ..., L[d-1]]. Those are often labeled theta.

Answer to your last question is Yes :)
Detail: Yeah these would be fit from the data. MOE offers that functionality through gp_hyper_opt. That is not built into get_next_points b/c you may not want to re-tune hyperparameters after every trial (b/c it's relatively expensive). So you have to specify hyperparam values o/w you end up with some very arbitrary defaults (1.0? I dont remember).

That said, keep a few things in mind:

  • if I have 10 dimensions and 2 points, hyperparameter tuning doesn't make any sense (tuning 11 parameters on 2 data points?). Here I suggest taking very rough estimates (try domain_length * 0.1 if you have really no idea) for hyperparams OR starting with an initial "grid" (cartesian, random latin hypercube, straight random, etc)
  • you need to specify a reasonable hyperparameter domain. example: if your spatial domain is [0, 100], having a length scale of 0.01 means you'd need ~10,000 points to fully cover the domain (in practice it may be less depending on the shape of the fcn). Similarly, a length scale of 1000 means 1 point would nearly fully determine the behavior. So you have to think about how your objective may vary when you make the choice.
  • with many points, each new addition probably is not drastically modifying the hyperparams, so tuning every time may not be critical

@robsmith11
Copy link

robsmith11 commented Jan 7, 2019

@suntzu86 's explanation makes sense, but I'm still getting the same error with the original example after adding the following to the request:

"covariance_info":{"covariance_type":"square_exponential","hyperparameters":[1.0,0.1]}

What else is required to perform multiple samples?

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

3 participants