[Question] How to configure model with custom settings/kwargs in generation strategy
See original GitHub issueThank you for your continuous support.
I have two follow-up questions about #278.
-
What should I do to pass my factory functions to
get_botorch
? I understood that I can use BoTorch with Ax by setting factory functions (e.g._get_and_fit_simple_custom_gp
for custom GP model andget_scalarized_UCB
for custom acquisition function) toget_botorch
’s argumentmodel_constructor
andacqf_constructor
respectively. @lena-kashtelyan told me I can useGenerationStep(model=get_botorch, ...)
. It is very simple but I don’t know how to pass my factory functions to BoTorch. -
Is there any way to confirm what kernel and acquisition function are used? I changed my
GenerationStrategy
to useModels.SOBOL
andget_botorch
. Then, the result of optimization was changed. But I didn’t know whether the kernel function and the acquisition function were changed because I didn’t pass my factory functions toget_botorch
. So, can I confirm what kernel and acquisition function are used in optimization?
My current code is like below:
class RBFGP(SingleTaskGP, GPyTorchModel):
_num_outputs = 2
# __init__ and forward function are defined.
# factory function for GP model
def get_RBFGP(Xs, Ys, **kwargs):
model = RBFGP(Xs[0], Ys[0])
mll = ExactMarginalLogLikelihood(...)
fit_gpytorch_model(mll)
return model
# factory function for acquisition function PI
def get_qPI(
model: Model,
best_f: Union[float, Tensor],
**kwargs: Any,
) -> AcquisitionFunction:
return qProbabilityOfImprovement(model=model, best_f=best_f)
gs = GenerationStrategy(
steps=[
GenerationStep(model=Models.SOBOL, num_arms=5),
GenerationStep(model=get_botorch, num_arms=-1),
]
)
# initialize client, set up experiment, and optimize
Maybe I have misunderstood, so any advice would be greatly appreciated. And, please ask me if you want to know the details of my code.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
Thank you for your explanation. I could understand about the correlation. Assuming no correlation in the observation noise is OK in my case.
I also could understand the flow and inputs of
SingleTaskGP
. This is very helpful when understanding Ax and debugging. And finally, the factory function for kernel has worked well!But,
RuntimeError
was occurred in the factory function for acquisition function.I used this page as a reference that you told me before. In
qProbabilityOfImprovement
, we need to passbest_f
. Is it correct way to calculatebest_f
?Of course, I’m glad to be more user friendly, but issues and your answers help me. In fact, I could make my experimental data optimization program by referring issues about black box optimization. Thank you for your all supports!
Thank you for your quick response.
I understand that
best_f
depends onobjective
.Of course, I must run the optimization loop many times when I compare these performances. I ran only 5 times. On the other hand almost result of
Models.GPEI
were within outcome constraint, the results of Matern + qNEI had never been within outcome constraint. I will run the optimization loop more time, but it takes a little long time (about 10 min a trial). So, I’ll report its results as another issue if there is a gap between the results ofModels.GPEI
and Matern + qNEI.Thank you for teaching me the details of qNEI. A noise is involved in my case too. So, I’ll use qNEI.
I really appreciate your supports. With all your help, I finally changed kernel and acquisition function.