-
Notifications
You must be signed in to change notification settings - Fork 75
New acquisition functions #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b866f56
Add human readable id to example tests
Scienfitz 71d4d62
Adapt deprecated assignment
Scienfitz a079ae7
Make non-MC ACQF error more precise
Scienfitz d69905c
Remove debotorchize
Scienfitz 8503d47
Fix streamlit example
Scienfitz 0cdef0f
Implement to_botorch conversion
Scienfitz d7598e7
Add acqf iteration tests
Scienfitz e38f02a
Reorder acqfs
Scienfitz 18e2c60
Add simple regret
Scienfitz f54793b
Add q-noisy variants
Scienfitz 99dd0d6
Add log variants
Scienfitz eedecf3
Extend hypothesis
Scienfitz b163f91
Update CHANGELOG.md
Scienfitz d7ef923
Use custom classproperty
Scienfitz 6e40556
Replace botorch factory
Scienfitz f2204f8
Add pruning option
Scienfitz 0b9b27f
Ignore is_mc in docs
Scienfitz 064c61a
Add chaining deprecation reference
Scienfitz 8e2dcf3
Update prune_basline validator
Scienfitz 11fc52a
Make adapter module private
Scienfitz 95ade5e
Reorder acqfs in init
Scienfitz 21a48a3
Simplify test file parameterization
Scienfitz 81b422a
Reorder acqf hypothesis according to complexity
Scienfitz 4168475
Improve seq greedy error handling
Scienfitz 16db826
Adjust seq greedy continuous error handling
Scienfitz 580c3ff
Adjust seq greedy hybrid error handling
Scienfitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,45 @@ | ||
| """Adapter for making BoTorch's acquisition functions work with BayBE models.""" | ||
|
|
||
| from typing import Any, Callable, Optional | ||
|
|
||
| import gpytorch.distributions | ||
| from botorch.models.gpytorch import Model | ||
| from botorch.posteriors import Posterior | ||
| from botorch.posteriors.gpytorch import GPyTorchPosterior | ||
| from torch import Tensor | ||
|
|
||
| from baybe.surrogates.base import Surrogate | ||
|
|
||
|
|
||
| class AdapterModel(Model): | ||
| """A BoTorch model that uses a BayBE surrogate model for posterior computation. | ||
|
|
||
| Can be used, for example, as an adapter layer for making a BayBE | ||
| surrogate model usable in conjunction with BoTorch acquisition functions. | ||
|
|
||
| Args: | ||
| surrogate: The internal surrogate model | ||
| """ | ||
|
|
||
| def __init__(self, surrogate: Surrogate): | ||
| super().__init__() | ||
| self._surrogate = surrogate | ||
|
|
||
| @property | ||
| def num_outputs(self) -> int: # noqa: D102 | ||
| # See base class. | ||
| # TODO: So far, the usage is limited to single-output models. | ||
| return 1 | ||
|
|
||
| def posterior( # noqa: D102 | ||
| self, | ||
| X: Tensor, | ||
| output_indices: Optional[list[int]] = None, | ||
| observation_noise: bool = False, | ||
| posterior_transform: Optional[Callable[[Posterior], Posterior]] = None, | ||
| **kwargs: Any, | ||
| ) -> Posterior: | ||
| # See base class. | ||
| mean, var = self._surrogate.posterior(X) | ||
| mvn = gpytorch.distributions.MultivariateNormal(mean, var) | ||
| return GPyTorchPosterior(mvn) |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.