-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from ChristopherMayes/bugfixes
Bugfixes and log acquisition function implementation
- Loading branch information
Showing
7 changed files
with
487 additions
and
6 deletions.
There are no files selected for viewing
409 changes: 409 additions & 0 deletions
409
docs/examples/single_objective_bayes_opt/log_transformed_tutorial.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
xopt/generators/bayesian/custom_botorch/log_acquisition_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import torch | ||
from botorch.acquisition import AcquisitionFunction | ||
from botorch.utils import t_batch_mode_transform | ||
from torch import Tensor | ||
from torch.nn import Module | ||
from torch.nn.functional import softplus | ||
|
||
|
||
class LogAcquisitionFunction(AcquisitionFunction): | ||
def __init__( | ||
self, | ||
acq_function: AcquisitionFunction, | ||
) -> None: | ||
Module.__init__(self) | ||
self.acq_func = acq_function | ||
|
||
@t_batch_mode_transform(expected_q=1, assert_output_shape=False) | ||
def forward(self, X: Tensor) -> Tensor: | ||
# apply a softplus transform to avoid numerical gradient issues | ||
return torch.log(softplus(self.acq_func(X), 20)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters