Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions botorch/acquisition/analytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,12 +1078,20 @@ def forward(self, X: Tensor) -> Tensor:
t-batches of ``d``-dim design points each.

Returns:
A ``(b1 x ... x bk)``-dim Tensor of Posterior Mean values at the given
design points ``X``.
A ``(b1 x ... x bk)``-dim Tensor of scalarized Posterior Mean values
at the given design points ``X``.
"""
# (b1 x ... x bk) x q x 1
mean, _ = self._mean_and_sigma(X, compute_sigma=False)
return mean.squeeze(-1) @ self.weights
# ScalarizedPosteriorMean cannot use self._mean_and_sigma, since that squeezes
# the q-dim.
self.to(X) # Sync weights buffer to X's device/dtype
posterior = self.model.posterior(
X=X, posterior_transform=self.posterior_transform
)
# posterior.mean has shape (b1 x ... x bk) x q x m
# squeeze(-1) removes m (should be 1), giving (b1 x ... x bk) x q
mean = posterior.mean.squeeze(-1)
# @ self.weights: (b1 x ... x bk) x q @ q -> (b1 x ... x bk)
return mean @ self.weights


class PosteriorStandardDeviation(AnalyticAcquisitionFunction):
Expand Down