Skip to content
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

Conditional solver selection #330

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
are not passed on to the GPyTorch kernels
- Positive-valued kernel attributes are now correctly handled by validators
and hypothesis strategies
- Reverted `fit_gpytorch_mll` call back to old `fit_gpytorch_mll_torch` call until
finetuning is achieved
- As a temporary workaround to compensate for missing `IndexKernel` priors,
`fit_gpytorch_mll_torch` is used instead of `fit_gpytorch_mll` when a `TaskParameter`
is present, which acts as regularization via early stopping during model fitting

### Deprecations
- `SequentialGreedyRecommender` class replaced with `BotorchRecommender`
Expand Down
10 changes: 8 additions & 2 deletions baybe/surrogates/gaussian_process/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def _fit(self, searchspace: SearchSpace, train_x: Tensor, train_y: Tensor) -> No
import botorch
import gpytorch
import torch
from botorch.optim.fit import fit_gpytorch_mll_torch

# identify the indexes of the task and numeric dimensions
# TODO: generalize to multiple task parameters
Expand Down Expand Up @@ -139,4 +138,11 @@ def _fit(self, searchspace: SearchSpace, train_x: Tensor, train_y: Tensor) -> No
likelihood=likelihood,
)
mll = gpytorch.ExactMarginalLogLikelihood(self._model.likelihood, self._model)
fit_gpytorch_mll_torch(mll, step_limit=100)

# TODO: This is a simple temporary workaround to avoid model overfitting
# via early stopping in the presence of task parameters, which currently
# have no prior configured.
if n_task_params > 0:
botorch.optim.fit.fit_gpytorch_mll_torch(mll, step_limit=200)
else:
botorch.fit.fit_gpytorch_mll(mll)
Loading