From 9e27d0cccfbe21c274023cb52ed71b72d46daba7 Mon Sep 17 00:00:00 2001 From: Sait Cakmak Date: Wed, 18 Sep 2024 16:03:54 -0700 Subject: [PATCH] Remove `transform=None` from GPyTorch constraints Differential Revision: D62993873 --- botorch/models/contextual_multioutput.py | 4 +--- botorch/models/gp_regression.py | 4 +--- botorch/models/multitask.py | 1 - botorch/models/pairwise_gp.py | 2 +- botorch/models/transforms/input.py | 1 - botorch/models/utils/gpytorch_modules.py | 4 +--- 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/botorch/models/contextual_multioutput.py b/botorch/models/contextual_multioutput.py index e303315d7b..a082edb6cb 100644 --- a/botorch/models/contextual_multioutput.py +++ b/botorch/models/contextual_multioutput.py @@ -141,9 +141,7 @@ def __init__( ) self.task_covar_module_base = RBFKernel( ard_num_dims=n_embs, - lengthscale_constraint=Interval( - 0.0, 2.0, transform=None, initial_value=1.0 - ), + lengthscale_constraint=Interval(0.0, 2.0, initial_value=1.0), ) self.to(train_X) diff --git a/botorch/models/gp_regression.py b/botorch/models/gp_regression.py index dfb7a637b6..207b638db8 100644 --- a/botorch/models/gp_regression.py +++ b/botorch/models/gp_regression.py @@ -306,9 +306,7 @@ def __init__( noise_likelihood = GaussianLikelihood( noise_prior=SmoothedBoxPrior(-3, 5, 0.5, transform=torch.log), batch_shape=self._aug_batch_shape, - noise_constraint=GreaterThan( - MIN_INFERRED_NOISE_LEVEL, transform=None, initial_value=1.0 - ), + noise_constraint=GreaterThan(MIN_INFERRED_NOISE_LEVEL, initial_value=1.0), ) # Likelihood will always get evaluated with transformed X, so we need to # transform the training data before constructing the noise model. diff --git a/botorch/models/multitask.py b/botorch/models/multitask.py index 092639f250..be679347f4 100644 --- a/botorch/models/multitask.py +++ b/botorch/models/multitask.py @@ -483,7 +483,6 @@ def __init__( noise_prior=noise_prior, noise_constraint=GreaterThan( MIN_INFERRED_NOISE_LEVEL, - transform=None, initial_value=noise_prior.mode, ), rank=kwargs.get("likelihood_rank", 0), diff --git a/botorch/models/pairwise_gp.py b/botorch/models/pairwise_gp.py index e45f058755..f52af24b6d 100644 --- a/botorch/models/pairwise_gp.py +++ b/botorch/models/pairwise_gp.py @@ -272,7 +272,7 @@ def __init__( ard_num_dims=self.dim, lengthscale_prior=ls_prior, lengthscale_constraint=GreaterThan( - lower_bound=1e-4, transform=None, initial_value=ls_prior_mode + lower_bound=1e-4, initial_value=ls_prior_mode ), dtype=torch.float64, ), diff --git a/botorch/models/transforms/input.py b/botorch/models/transforms/input.py index 329e407c50..4c48053119 100644 --- a/botorch/models/transforms/input.py +++ b/botorch/models/transforms/input.py @@ -1016,7 +1016,6 @@ def __init__( p_name = f"concentration{i}" constraint = GreaterThan( self._min_concentration_level, - transform=None, # set the initial value to be the identity transformation initial_value=1.0, ) diff --git a/botorch/models/utils/gpytorch_modules.py b/botorch/models/utils/gpytorch_modules.py index 9f096d6bf7..621aeb2cd0 100644 --- a/botorch/models/utils/gpytorch_modules.py +++ b/botorch/models/utils/gpytorch_modules.py @@ -65,7 +65,6 @@ def get_gaussian_likelihood_with_gamma_prior( batch_shape=batch_shape, noise_constraint=GreaterThan( MIN_INFERRED_NOISE_LEVEL, - transform=None, initial_value=noise_prior_mode, ), ) @@ -91,7 +90,6 @@ def get_gaussian_likelihood_with_lognormal_prior( batch_shape=batch_shape, noise_constraint=GreaterThan( MIN_INFERRED_NOISE_LEVEL, - transform=None, initial_value=noise_prior.mode, ), ) @@ -125,7 +123,7 @@ def get_covar_module_with_dim_scaled_prior( batch_shape=batch_shape, lengthscale_prior=lengthscale_prior, lengthscale_constraint=GreaterThan( - 2.5e-2, transform=None, initial_value=lengthscale_prior.mode + 2.5e-2, initial_value=lengthscale_prior.mode ), # pyre-ignore[6] GPyTorch type is unnecessarily restrictive. active_dims=active_dims,