Gradient-Free-Optimizers
Gradient-Free-Optimizers copied to clipboard
API changes for v2
In this issue the progress for the API-changes for v2 is shown.
The objective-function parameter might make more sense in the optimizer-class instead of the search-method. Parameters in the method should be data you would want to change from one search to the next. It does not make sense to me to change the objective-function but not the search-space. So the new API-design would look like this:
import numpy as np
from gradient_free_optimizers import RandomSearchOptimizer
def parabola_function(para):
loss = para["x"] * para["x"]
return -loss
search_space = {"x": np.arange(-10, 10, 0.1)}
opt = RandomSearchOptimizer(parabola_function, search_space)
opt.search(n_iter=100000)
since there are multiple kinds of "powell's methods", the existing "powell's method" in GFO will be renames to "Powell's Conjugate Direction Method" in v2.0
The objective-function and the search-space are not optimizer specific parameters. It makes more sense to move the search-space argument to the search-method. So the v2 API could look like this:
import numpy as np
from gradient_free_optimizers import RandomSearchOptimizer
def parabola_function(para):
loss = para["x"] * para["x"]
return -loss
search_space = {"x": np.arange(-10, 10, 0.1)}
opt = RandomSearchOptimizer()
opt.search(parabola_function, search_space, n_iter=100000)
This is also true for initialize and constraints and the random_state.