Skip to content

Commit ca4226e

Browse files
SebastianAmentfacebook-github-bot
authored andcommitted
qLogNEI (#1937)
Summary: Pull Request resolved: #1937 This commit introduces `qLogNoisyExpectedImprovement` (`qLogNEI`) a cousin of `qLogEI`. Similar to `qLogEI` and in contrast to `q(N)EI`, it generally exhibits strong and smooth gradients, leading to better acquisition function optimization and Bayesian optimization as a result. Reviewed By: Balandat Differential Revision: D47439161 fbshipit-source-id: 8fd1aec52761dfc16b22ddd39f099cd207625966
1 parent dfd2a9b commit ca4226e

File tree

6 files changed

+871
-7
lines changed

6 files changed

+871
-7
lines changed

botorch/acquisition/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from botorch.acquisition.logei import (
3838
LogImprovementMCAcquisitionFunction,
3939
qLogExpectedImprovement,
40+
qLogNoisyExpectedImprovement,
4041
)
4142
from botorch.acquisition.max_value_entropy_search import (
4243
MaxValueBase,
@@ -96,6 +97,7 @@
9697
"qExpectedImprovement",
9798
"LogImprovementMCAcquisitionFunction",
9899
"qLogExpectedImprovement",
100+
"qLogNoisyExpectedImprovement",
99101
"qKnowledgeGradient",
100102
"MaxValueBase",
101103
"qMultiFidelityKnowledgeGradient",

botorch/acquisition/input_constructors.py

Lines changed: 149 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@
4747
qKnowledgeGradient,
4848
qMultiFidelityKnowledgeGradient,
4949
)
50-
from botorch.acquisition.logei import qLogExpectedImprovement
50+
from botorch.acquisition.logei import (
51+
qLogExpectedImprovement,
52+
qLogNoisyExpectedImprovement,
53+
TAU_MAX,
54+
TAU_RELU,
55+
)
5156
from botorch.acquisition.max_value_entropy_search import (
5257
qMaxValueEntropy,
5358
qMultiFidelityMaxValueEntropy,
@@ -450,7 +455,7 @@ def construct_inputs_qSimpleRegret(
450455
)
451456

452457

453-
@acqf_input_constructor(qExpectedImprovement, qLogExpectedImprovement)
458+
@acqf_input_constructor(qExpectedImprovement)
454459
def construct_inputs_qEI(
455460
model: Model,
456461
training_data: MaybeDict[SupervisedDataset],
@@ -508,6 +513,72 @@ def construct_inputs_qEI(
508513
return {**base_inputs, "best_f": best_f, "constraints": constraints, "eta": eta}
509514

510515

516+
@acqf_input_constructor(qLogExpectedImprovement)
517+
def construct_inputs_qLogEI(
518+
model: Model,
519+
training_data: MaybeDict[SupervisedDataset],
520+
objective: Optional[MCAcquisitionObjective] = None,
521+
posterior_transform: Optional[PosteriorTransform] = None,
522+
X_pending: Optional[Tensor] = None,
523+
sampler: Optional[MCSampler] = None,
524+
best_f: Optional[Union[float, Tensor]] = None,
525+
constraints: Optional[List[Callable[[Tensor], Tensor]]] = None,
526+
eta: Union[Tensor, float] = 1e-3,
527+
fat: bool = True,
528+
tau_max: float = TAU_MAX,
529+
tau_relu: float = TAU_RELU,
530+
**ignored: Any,
531+
) -> Dict[str, Any]:
532+
r"""Construct kwargs for the `qExpectedImprovement` constructor.
533+
534+
Args:
535+
model: The model to be used in the acquisition function.
536+
training_data: Dataset(s) used to train the model.
537+
objective: The objective to be used in the acquisition function.
538+
posterior_transform: The posterior transform to be used in the
539+
acquisition function.
540+
X_pending: A `m x d`-dim Tensor of `m` design points that have been
541+
submitted for function evaluation but have not yet been evaluated.
542+
Concatenated into X upon forward call.
543+
sampler: The sampler used to draw base samples. If omitted, uses
544+
the acquisition functions's default sampler.
545+
best_f: Threshold above (or below) which improvement is defined.
546+
constraints: A list of constraint callables which map a Tensor of posterior
547+
samples of dimension `sample_shape x batch-shape x q x m`-dim to a
548+
`sample_shape x batch-shape x q`-dim Tensor. The associated constraints
549+
are considered satisfied if the output is less than zero.
550+
eta: Temperature parameter(s) governing the smoothness of the sigmoid
551+
approximation to the constraint indicators. For more details, on this
552+
parameter, see the docs of `compute_smoothed_feasibility_indicator`.
553+
fat: Toggles the logarithmic / linear asymptotic behavior of the smooth
554+
approximation to the ReLU.
555+
tau_max: Temperature parameter controlling the sharpness of the smooth
556+
approximations to max.
557+
tau_relu: Temperature parameter controlling the sharpness of the smooth
558+
approximations to ReLU.
559+
ignored: Not used.
560+
561+
Returns:
562+
A dict mapping kwarg names of the constructor to values.
563+
"""
564+
return {
565+
**construct_inputs_qEI(
566+
model=model,
567+
training_data=training_data,
568+
objective=objective,
569+
posterior_transform=posterior_transform,
570+
X_pending=X_pending,
571+
sampler=sampler,
572+
best_f=best_f,
573+
constraints=constraints,
574+
eta=eta,
575+
),
576+
"fat": fat,
577+
"tau_max": tau_max,
578+
"tau_relu": tau_relu,
579+
}
580+
581+
511582
@acqf_input_constructor(qNoisyExpectedImprovement)
512583
def construct_inputs_qNEI(
513584
model: Model,
@@ -570,7 +641,6 @@ def construct_inputs_qNEI(
570641
assert_shared=True,
571642
first_only=True,
572643
)
573-
574644
return {
575645
**base_inputs,
576646
"X_baseline": X_baseline,
@@ -581,6 +651,82 @@ def construct_inputs_qNEI(
581651
}
582652

583653

654+
@acqf_input_constructor(qLogNoisyExpectedImprovement)
655+
def construct_inputs_qLogNEI(
656+
model: Model,
657+
training_data: MaybeDict[SupervisedDataset],
658+
objective: Optional[MCAcquisitionObjective] = None,
659+
posterior_transform: Optional[PosteriorTransform] = None,
660+
X_pending: Optional[Tensor] = None,
661+
sampler: Optional[MCSampler] = None,
662+
X_baseline: Optional[Tensor] = None,
663+
prune_baseline: Optional[bool] = True,
664+
cache_root: Optional[bool] = True,
665+
constraints: Optional[List[Callable[[Tensor], Tensor]]] = None,
666+
eta: Union[Tensor, float] = 1e-3,
667+
fat: bool = True,
668+
tau_max: float = TAU_MAX,
669+
tau_relu: float = TAU_RELU,
670+
**ignored: Any,
671+
):
672+
r"""Construct kwargs for the `qNoisyExpectedImprovement` constructor.
673+
674+
Args:
675+
model: The model to be used in the acquisition function.
676+
training_data: Dataset(s) used to train the model.
677+
objective: The objective to be used in the acquisition function.
678+
posterior_transform: The posterior transform to be used in the
679+
acquisition function.
680+
X_pending: A `m x d`-dim Tensor of `m` design points that have been
681+
submitted for function evaluation but have not yet been evaluated.
682+
Concatenated into X upon forward call.
683+
sampler: The sampler used to draw base samples. If omitted, uses
684+
the acquisition functions's default sampler.
685+
X_baseline: A `batch_shape x r x d`-dim Tensor of `r` design points
686+
that have already been observed. These points are considered as
687+
the potential best design point. If omitted, checks that all
688+
training_data have the same input features and take the first `X`.
689+
prune_baseline: If True, remove points in `X_baseline` that are
690+
highly unlikely to be the best point. This can significantly
691+
improve performance and is generally recommended.
692+
constraints: A list of constraint callables which map a Tensor of posterior
693+
samples of dimension `sample_shape x batch-shape x q x m`-dim to a
694+
`sample_shape x batch-shape x q`-dim Tensor. The associated constraints
695+
are considered satisfied if the output is less than zero.
696+
eta: Temperature parameter(s) governing the smoothness of the sigmoid
697+
approximation to the constraint indicators. For more details, on this
698+
parameter, see the docs of `compute_smoothed_feasibility_indicator`.
699+
fat: Toggles the logarithmic / linear asymptotic behavior of the smooth
700+
approximation to the ReLU.
701+
tau_max: Temperature parameter controlling the sharpness of the smooth
702+
approximations to max.
703+
tau_relu: Temperature parameter controlling the sharpness of the smooth
704+
approximations to ReLU.
705+
ignored: Not used.
706+
707+
Returns:
708+
A dict mapping kwarg names of the constructor to values.
709+
"""
710+
return {
711+
**construct_inputs_qNEI(
712+
model=model,
713+
training_data=training_data,
714+
objective=objective,
715+
posterior_transform=posterior_transform,
716+
X_pending=X_pending,
717+
sampler=sampler,
718+
X_baseline=X_baseline,
719+
prune_baseline=prune_baseline,
720+
cache_root=cache_root,
721+
constraint=constraints,
722+
eta=eta,
723+
),
724+
"fat": fat,
725+
"tau_max": tau_max,
726+
"tau_relu": tau_relu,
727+
}
728+
729+
584730
@acqf_input_constructor(qProbabilityOfImprovement)
585731
def construct_inputs_qPI(
586732
model: Model,

0 commit comments

Comments
 (0)