Skip to content

Commit

Permalink
Allow monotonic rejection GP to initialize its inducing point allocat…
Browse files Browse the repository at this point in the history
…or from config. (facebookresearch#485)

Summary:
Pull Request resolved: facebookresearch#485

Monotonic rejection GP used to completely ignore any inducing point config, now it follows other models.

Differential Revision: D67225873
  • Loading branch information
JasonKChow authored and facebook-github-bot committed Dec 14, 2024
1 parent 521af32 commit 151e5a0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions aepsych/models/monotonic_rejection_gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from aepsych.means.constant_partial_grad import ConstantMeanPartialObsGrad
from aepsych.models.base import AEPsychMixin
from aepsych.models.inducing_points import AutoAllocator, SobolAllocator
from aepsych.models.utils import select_inducing_points
from aepsych.utils import _process_bounds, get_optimizer_options, promote_0d
from botorch.fit import fit_gpytorch_mll
from botorch.models.utils.inducing_point_allocators import InducingPointAllocator
Expand Down Expand Up @@ -99,9 +100,10 @@ def __init__(
# TODO: This allocator *must* be SobolAllocator and not the set one. This
# suggests that this model doesn't actually properly use data for inducing
# points properly.
inducing_points = SobolAllocator(
bounds=torch.stack([lb, ub]), dim=self.dim
).allocate_inducing_points(num_inducing=self.inducing_size)
inducing_points = select_inducing_points(
allocator=SobolAllocator(bounds=torch.stack([lb, ub]), dim=self.dim),
inducing_size=self.inducing_size,
)

inducing_points_aug = self._augment_with_deriv_index(inducing_points, 0)
variational_distribution = CholeskyVariationalDistribution(
Expand Down Expand Up @@ -166,10 +168,11 @@ def fit(self, train_x: torch.Tensor, train_y: torch.Tensor, **kwargs) -> None:
"""
self.set_train_data(train_x, train_y)

self.inducing_points = self.inducing_point_method.allocate_inducing_points(
num_inducing=self.inducing_size,
self.inducing_points = select_inducing_points(
allocator=self.inducing_point_method,
inducing_size=self.inducing_size,
covar_module=self.covar_module,
inputs=self._augment_with_deriv_index(self.train_inputs[0], 0),
X=self._augment_with_deriv_index(self.train_inputs[0], 0),
)
self._set_model(train_x, train_y)

Expand Down

0 comments on commit 151e5a0

Please sign in to comment.