Skip to content

Commit

Permalink
Fix KG for minimization problems
Browse files Browse the repository at this point in the history
  • Loading branch information
ziatdinovmax committed Aug 27, 2023
1 parent bfcf305 commit 15b19b6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gpax/acquisition/base_acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def poi(model: Type[ExactGP],
def kg(model: Type[ExactGP],
X_new: jnp.ndarray,
sample: Dict[str, jnp.ndarray],
n: int = 1,
n: int = 10,
maximize: bool = True,
noiseless: bool = True,
rng_key: Optional[jnp.ndarray] = None,
Expand All @@ -178,7 +178,7 @@ def kg(model: Type[ExactGP],
model: trained model
X: new inputs with shape (N, D), where D is a feature dimension
sample: a single sample with model parameters
n: Number fo simulated samples (Defaults to 1)
n: Number fo simulated samples (Defaults to 10)
maximize: If True, assumes that BO is solving maximization problem
noiseless:
Noise-free prediction. It is set to False by default as new/unseen data is assumed
Expand Down Expand Up @@ -207,7 +207,10 @@ def kg_for_one_point(x_aug, y_aug, mean_o):
y_fant = mean_aug.max() if maximize else mean_aug.min()
# Compute adn return the improvement compared to the original maximum mean value
mean_o_best = mean_o.max() if maximize else mean_o.min()
return y_fant - mean_o_best
u = y_fant - mean_o_best
if not maximize:
u = -u
return u

# Get posterior distribution for candidate points
mean, cov = model.get_mvn_posterior(X_new, *sample, noiseless=noiseless, **kwargs)
Expand Down

0 comments on commit 15b19b6

Please sign in to comment.