vthorey / benderopt Goto Github PK
View Code? Open in Web Editor NEWBlack-box optimization library
License: MIT License
Black-box optimization library
License: MIT License
Hi, is there a way to provide an initial guess or starting point for the exploration? Should I just build a custom OptimizationProblem object with an observation already filled in? I tried doing this like the example using OptimizationProblem.from_json
, but it seems that it won't take a dictionary, only strings or other objects.
I'm using minimize
and I have variables named x
and y
. Both in the closed range [0, 10]
. Is it possible to give a constraint in which y
is larger than x
?
I can implement it on my own by returning a large value in my function but is there a more correct way to do that?
Problem: Attempting to sample from a categorial variable, defined as a list containing np.arrays (see example below), generates an error in the np.random.choice()
function used to draw a sample in function generate_samples_categorical()
in ~/stats/categorical.py
. The error message of the np.random.choice()
function states that "a is not a 1-D variable".
control_handles_dict['Nc']['bounds_values'] = [ np.array([1.5]), np.array([2.0]), np.array([2.5]) ]
optimization_problem_parameters = [
{
"name": "x1",
"category" : "categorical",
"search_space" : {
"values" : control_handles_dict['Nc']['bounds_values']
}
},
{
"name": "x2",
"category" : "categorical",
"search_space" : {
"values" : control_handles_dict['Nc']['bounds_values']
}
},
]
some_obj_fun(**x):
return x['x1'] + x['x2']
minimize(obj_fun, optimization_problem_parameters)
If one of the np.arrays()
in control_handles_dict['Nc']['bounds_values']
is swapped for another data type, f.i.,
control_handles_dict['Nc']['bounds_values'] = [ 'a', np.array([2.0]), np.array([2.5]) ]
the error does not occur and np.random.choice()
draws a sample from the above list.
Swapping numpy.random.choice()
out for random.choices()
in function generate_samples_categorical()
in ~/stats/categorical.py
resolves the issue.
import random
def generate_samples_categorical(values, probabilities, size=1):
"""Generate sample for categorical data with probability probabilities."""
return random.choices(values, weights=probabilities, k=size)
Let me know if the above explanation is clear and thanks in advance.
Adding new optimizers is quite cumbersome now, since I have to modify a dictionary in your module to add them.
It would be better if minimize
was also able to take optimizer directly, instead of a type.
Will probably make a PR at some point.
Hi,
Thank you so much for this package! Was looking for a hyperparameter optimizer that was both simple and easy to integrate and this just hit the nail on the head.
However, I have to access the underlying classes and methods to fit my use case via a small hack:
import benderopt.minimize as benderopt
benderopt.OptimizationProblem...
I suggest to allow more flexibility by adding these to __init__.py
instead. The minimize
point of access does not work for me, I imagine many people would like a slightly lower level access too.
If the decision is not to go in this direction I hope you keep the backdoor open ๐
Hi, first of all thank you for this excellent optimization package.
When setting wrong settings for an uniform parameter:
{ "name": "WestWWR", "category": "uniform", "search_space": { "low": 0.0, "high": 0.15, "step": 0.20} },
I get ValidationError: 'step' must be strictly superior than 'high'
Shouldn't it be the other way around ?
'high' must be strictly superior than 'step'
Hi, I tried to run the file minimizer.py, however, it raised an error:
Traceback (most recent call last):
File "/home/zippingsugar/anaconda2/envs/HLSTS/lib/python2.7/site-packages/benderopt-1.3.2-py2.7.egg/benderopt/minimizer.py", line 44, in <module>
f, optimization_problem_parameters=optimization_problem_parameters, number_of_evaluation=100)
File "/home/zippingsugar/anaconda2/envs/HLSTS/lib/python2.7/site-packages/benderopt-1.3.2-py2.7.egg/benderopt/minimizer.py", line 19, in minimize
optimization_problem = OptimizationProblem.from_list(optimization_problem_parameters)
File "/home/zippingsugar/anaconda2/envs/HLSTS/lib/python2.7/site-packages/benderopt-1.3.2-py2.7.egg/benderopt/base/optimization_problem.py", line 259, in from_list
return cls(parameters)
File "/home/zippingsugar/anaconda2/envs/HLSTS/lib/python2.7/site-packages/benderopt-1.3.2-py2.7.egg/benderopt/base/optimization_problem.py", line 80, in __init__
raise ValidationError(message="'parameters' must be a list of Parameter")
benderopt.validation.utils.ValidationError: 'parameters' must be a list of Parameter
I guess there were some modifications in the code and the example wasn't updated in time.
Oh, I realized this error might come from using python 2.7. I've modified several places and made it compatible with py2.7.
As part of my function (checking hyperparameters for NN training) I need to reset all global random number generators in python, which leads to optimizers suggesting the same value on subsequent passes.
Would be great if optimizers used their own generators.
I might create a PR in the future.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.