Skip to content

Commit d14977c

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Simplify qMultiObjectiveMaxValueEntropy.__init__ (#2433)
Summary: Pull Request resolved: #2433 I tried to see if I could eliminate the use of model converter code in `qMultiObjectiveMaxValueEntropy` with a reasonable time investment, but couldn't go much further than this. The in-line comments about tensor shapes do not appear to be fully accurate, particularly those in `qMaxValueEntropy._compute_information_gain`. They seem to have been written for the multi-fidelity case and are confusing when viewed without that context. I may revisit this later. Reviewed By: SebastianAment Differential Revision: D59834357 fbshipit-source-id: 8b70f4dc048825517341cbc1f6897f1f52cc6936
1 parent 5b072ce commit d14977c

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

botorch/acquisition/max_value_entropy_search.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,20 @@ def forward(self, X: Tensor) -> Tensor:
123123
Returns:
124124
A `batch_shape`-dim Tensor of MVE values at the given design points `X`.
125125
"""
126-
# Compute the posterior, posterior mean, variance and std
126+
# Compute the posterior, posterior mean, variance and std.
127127
posterior = self.model.posterior(
128128
X.unsqueeze(-3),
129129
observation_noise=False,
130130
posterior_transform=self.posterior_transform,
131131
)
132-
# batch_shape x num_fantasies x (m) x 1
132+
# batch_shape x num_fantasies x (m)
133133
mean = self.weight * posterior.mean.squeeze(-1).squeeze(-1)
134134
variance = posterior.variance.clamp_min(CLAMP_LB).view_as(mean)
135135
ig = self._compute_information_gain(
136136
X=X, mean_M=mean, variance_M=variance, covar_mM=variance.unsqueeze(-1)
137137
)
138-
return ig.mean(dim=0) # average over fantasies
138+
# Average over fantasies, ig is of shape `num_fantasies x batch_shape x (m)`.
139+
return ig.mean(dim=0)
139140

140141
def set_X_pending(self, X_pending: Optional[Tensor] = None) -> None:
141142
r"""Set pending design points.

botorch/acquisition/multi_objective/max_value_entropy_search.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ def __init__(
109109
model_list_to_batched(model) if isinstance(model, ModelListGP) else model
110110
)
111111
self._init_model = batched_mo_model
112-
self.mo_model = batched_mo_model
113-
self.model = batched_multi_output_to_single_output(
114-
batch_mo_model=batched_mo_model
115-
)
116112
self.fantasies_sampler = SobolQMCNormalSampler(
117113
sample_shape=torch.Size([num_fantasies])
118114
)
@@ -121,12 +117,8 @@ def __init__(
121117
self.maximize = True
122118
self.weight = 1.0
123119
self.sample_pareto_frontiers = sample_pareto_frontiers
124-
125-
# this avoids unnecessary model conversion if X_pending is None
126-
if X_pending is None:
127-
self._sample_max_values()
128-
else:
129-
self.set_X_pending(X_pending)
120+
# Set X_pending, register converted model and sample max values.
121+
self.set_X_pending(X_pending)
130122
# This avoids attribute errors in qMaxValueEntropy code.
131123
self.posterior_transform = None
132124

0 commit comments

Comments
 (0)