diff --git a/v/latest/api/_modules/botorch/models/approximate_gp.html b/v/latest/api/_modules/botorch/models/approximate_gp.html index 27b4b7517e..99c972ee3f 100644 --- a/v/latest/api/_modules/botorch/models/approximate_gp.html +++ b/v/latest/api/_modules/botorch/models/approximate_gp.html @@ -63,8 +63,8 @@
is None, and a `FixedNoiseGaussianLikelihood` with the given
noise observations if `train_Yvar` is not None.
covar_module: The module computing the covariance (Kernel) matrix.
- If omitted, use a `MaternKernel`.
+ If omitted, uses an `RBFKernel`.
mean_module: The mean function to be used. If omitted, use a
`ConstantMean`.
outcome_transform: An outcome transform that is applied to the
@@ -232,6 +232,7 @@ Source code for botorch.models.gp_regression
ard_num_dims=transformed_X.shape[-1],
batch_shape=self._aug_batch_shape,
)
+ # Used for subsetting along the output dimension. See Model.subset_output.
self._subset_batch_dict = {
"mean_module.raw_constant": -1,
"covar_module.raw_lengthscale": -3,
diff --git a/v/latest/api/_modules/botorch/models/gp_regression/index.html b/v/latest/api/_modules/botorch/models/gp_regression/index.html
index 2e958cc3d8..f29491d085 100644
--- a/v/latest/api/_modules/botorch/models/gp_regression/index.html
+++ b/v/latest/api/_modules/botorch/models/gp_regression/index.html
@@ -174,7 +174,7 @@ Source code for botorch.models.gp_regression
is None, and a `FixedNoiseGaussianLikelihood` with the given
noise observations if `train_Yvar` is not None.
covar_module: The module computing the covariance (Kernel) matrix.
- If omitted, use a `MaternKernel`.
+ If omitted, uses an `RBFKernel`.
mean_module: The mean function to be used. If omitted, use a
`ConstantMean`.
outcome_transform: An outcome transform that is applied to the
@@ -232,6 +232,7 @@ Source code for botorch.models.gp_regression
ard_num_dims=transformed_X.shape[-1],
batch_shape=self._aug_batch_shape,
)
+ # Used for subsetting along the output dimension. See Model.subset_output.
self._subset_batch_dict = {
"mean_module.raw_constant": -1,
"covar_module.raw_lengthscale": -3,
diff --git a/v/latest/api/_modules/botorch/models/gp_regression_fidelity.html b/v/latest/api/_modules/botorch/models/gp_regression_fidelity.html
index e5e4633056..ff9a2a1542 100644
--- a/v/latest/api/_modules/botorch/models/gp_regression_fidelity.html
+++ b/v/latest/api/_modules/botorch/models/gp_regression_fidelity.html
@@ -49,7 +49,6 @@ Source code for botorch.models.gp_regression_fidelity
from __future__ import annotations
import warnings
-
from typing import Any, Optional, Union
import torch
@@ -62,9 +61,9 @@ Source code for botorch.models.gp_regression_fidelity
)
from botorch.models.transforms.input import InputTransform
from botorch.models.transforms.outcome import OutcomeTransform
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from botorch.utils.datasets import SupervisedDataset
from gpytorch.kernels.kernel import ProductKernel
-from gpytorch.kernels.rbf_kernel import RBFKernel
from gpytorch.kernels.scale_kernel import ScaleKernel
from gpytorch.likelihoods.likelihood import Likelihood
from gpytorch.priors.torch_priors import GammaPrior
@@ -178,6 +177,7 @@ Source code for botorch.models.gp_regression_fidelity
outcome_transform=outcome_transform,
input_transform=input_transform,
)
+ # Used for subsetting along the output dimension. See Model.subset_output.
self._subset_batch_dict = {
"mean_module.raw_constant": -1,
"covar_module.raw_outputscale": -1,
@@ -305,10 +305,9 @@ Source code for botorch.models.gp_regression_fidelity
non_active_dims.add(iteration_fidelity)
active_dimsX = sorted(set(range(dim)) - non_active_dims)
kernels.append(
- RBFKernel(
+ get_covar_module_with_dim_scaled_prior(
ard_num_dims=len(active_dimsX),
batch_shape=aug_batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
active_dims=active_dimsX,
)
)
diff --git a/v/latest/api/_modules/botorch/models/gp_regression_fidelity/index.html b/v/latest/api/_modules/botorch/models/gp_regression_fidelity/index.html
index e5e4633056..ff9a2a1542 100644
--- a/v/latest/api/_modules/botorch/models/gp_regression_fidelity/index.html
+++ b/v/latest/api/_modules/botorch/models/gp_regression_fidelity/index.html
@@ -49,7 +49,6 @@ Source code for botorch.models.gp_regression_fidelity
from __future__ import annotations
import warnings
-
from typing import Any, Optional, Union
import torch
@@ -62,9 +61,9 @@ Source code for botorch.models.gp_regression_fidelity
)
from botorch.models.transforms.input import InputTransform
from botorch.models.transforms.outcome import OutcomeTransform
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from botorch.utils.datasets import SupervisedDataset
from gpytorch.kernels.kernel import ProductKernel
-from gpytorch.kernels.rbf_kernel import RBFKernel
from gpytorch.kernels.scale_kernel import ScaleKernel
from gpytorch.likelihoods.likelihood import Likelihood
from gpytorch.priors.torch_priors import GammaPrior
@@ -178,6 +177,7 @@ Source code for botorch.models.gp_regression_fidelity
outcome_transform=outcome_transform,
input_transform=input_transform,
)
+ # Used for subsetting along the output dimension. See Model.subset_output.
self._subset_batch_dict = {
"mean_module.raw_constant": -1,
"covar_module.raw_outputscale": -1,
@@ -305,10 +305,9 @@ Source code for botorch.models.gp_regression_fidelity
non_active_dims.add(iteration_fidelity)
active_dimsX = sorted(set(range(dim)) - non_active_dims)
kernels.append(
- RBFKernel(
+ get_covar_module_with_dim_scaled_prior(
ard_num_dims=len(active_dimsX),
batch_shape=aug_batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
active_dims=active_dimsX,
)
)
diff --git a/v/latest/api/_modules/botorch/models/gp_regression_mixed.html b/v/latest/api/_modules/botorch/models/gp_regression_mixed.html
index 1434df7d86..10d9ecd822 100644
--- a/v/latest/api/_modules/botorch/models/gp_regression_mixed.html
+++ b/v/latest/api/_modules/botorch/models/gp_regression_mixed.html
@@ -36,15 +36,13 @@ Source code for botorch.models.gp_regression_mixed
from botorch.models.kernels.categorical import CategoricalKernel
from botorch.models.transforms.input import InputTransform
from botorch.models.transforms.outcome import OutcomeTransform
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from botorch.utils.datasets import SupervisedDataset
from botorch.utils.transforms import normalize_indices
from gpytorch.constraints import GreaterThan
from gpytorch.kernels.kernel import Kernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.kernels.scale_kernel import ScaleKernel
-from gpytorch.likelihoods.gaussian_likelihood import GaussianLikelihood
from gpytorch.likelihoods.likelihood import Likelihood
-from gpytorch.priors import GammaPrior
from torch import Tensor
@@ -107,7 +105,7 @@ Source code for botorch.models.gp_regression_mixed
cont_kernel_factory: A method that accepts `batch_shape`, `ard_num_dims`,
and `active_dims` arguments and returns an instantiated GPyTorch
`Kernel` object to be used as the base kernel for the continuous
- dimensions. If omitted, this model uses a Matern-2.5 kernel as
+ dimensions. If omitted, this model uses an `RBFKernel` as
the kernel for the ordinal parameters.
likelihood: A likelihood. If omitted, use a standard
GaussianLikelihood with inferred noise level.
@@ -130,30 +128,7 @@ Source code for botorch.models.gp_regression_mixed
_, aug_batch_shape = self.get_batch_dimensions(train_X=train_X, train_Y=train_Y)
if cont_kernel_factory is None:
-
- def cont_kernel_factory(
- batch_shape: torch.Size,
- ard_num_dims: int,
- active_dims: list[int],
- ) -> MaternKernel:
- return MaternKernel(
- nu=2.5,
- batch_shape=batch_shape,
- ard_num_dims=ard_num_dims,
- active_dims=active_dims,
- lengthscale_constraint=GreaterThan(1e-04),
- )
-
- if likelihood is None and train_Yvar is None:
- # This Gamma prior is quite close to the Horseshoe prior
- min_noise = 1e-5 if train_X.dtype == torch.float else 1e-6
- likelihood = GaussianLikelihood(
- batch_shape=aug_batch_shape,
- noise_constraint=GreaterThan(
- min_noise, transform=None, initial_value=1e-3
- ),
- noise_prior=GammaPrior(0.9, 10.0),
- )
+ cont_kernel_factory = get_covar_module_with_dim_scaled_prior
d = train_X.shape[-1]
cat_dims = normalize_indices(indices=cat_dims, d=d)
diff --git a/v/latest/api/_modules/botorch/models/gp_regression_mixed/index.html b/v/latest/api/_modules/botorch/models/gp_regression_mixed/index.html
index 1434df7d86..10d9ecd822 100644
--- a/v/latest/api/_modules/botorch/models/gp_regression_mixed/index.html
+++ b/v/latest/api/_modules/botorch/models/gp_regression_mixed/index.html
@@ -36,15 +36,13 @@ Source code for botorch.models.gp_regression_mixed
from botorch.models.kernels.categorical import CategoricalKernel
from botorch.models.transforms.input import InputTransform
from botorch.models.transforms.outcome import OutcomeTransform
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from botorch.utils.datasets import SupervisedDataset
from botorch.utils.transforms import normalize_indices
from gpytorch.constraints import GreaterThan
from gpytorch.kernels.kernel import Kernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.kernels.scale_kernel import ScaleKernel
-from gpytorch.likelihoods.gaussian_likelihood import GaussianLikelihood
from gpytorch.likelihoods.likelihood import Likelihood
-from gpytorch.priors import GammaPrior
from torch import Tensor
@@ -107,7 +105,7 @@ Source code for botorch.models.gp_regression_mixed
cont_kernel_factory: A method that accepts `batch_shape`, `ard_num_dims`,
and `active_dims` arguments and returns an instantiated GPyTorch
`Kernel` object to be used as the base kernel for the continuous
- dimensions. If omitted, this model uses a Matern-2.5 kernel as
+ dimensions. If omitted, this model uses an `RBFKernel` as
the kernel for the ordinal parameters.
likelihood: A likelihood. If omitted, use a standard
GaussianLikelihood with inferred noise level.
@@ -130,30 +128,7 @@ Source code for botorch.models.gp_regression_mixed
_, aug_batch_shape = self.get_batch_dimensions(train_X=train_X, train_Y=train_Y)
if cont_kernel_factory is None:
-
- def cont_kernel_factory(
- batch_shape: torch.Size,
- ard_num_dims: int,
- active_dims: list[int],
- ) -> MaternKernel:
- return MaternKernel(
- nu=2.5,
- batch_shape=batch_shape,
- ard_num_dims=ard_num_dims,
- active_dims=active_dims,
- lengthscale_constraint=GreaterThan(1e-04),
- )
-
- if likelihood is None and train_Yvar is None:
- # This Gamma prior is quite close to the Horseshoe prior
- min_noise = 1e-5 if train_X.dtype == torch.float else 1e-6
- likelihood = GaussianLikelihood(
- batch_shape=aug_batch_shape,
- noise_constraint=GreaterThan(
- min_noise, transform=None, initial_value=1e-3
- ),
- noise_prior=GammaPrior(0.9, 10.0),
- )
+ cont_kernel_factory = get_covar_module_with_dim_scaled_prior
d = train_X.shape[-1]
cat_dims = normalize_indices(indices=cat_dims, d=d)
diff --git a/v/latest/api/_modules/botorch/models/gpytorch.html b/v/latest/api/_modules/botorch/models/gpytorch.html
index 9b22251c80..f01de465a9 100644
--- a/v/latest/api/_modules/botorch/models/gpytorch.html
+++ b/v/latest/api/_modules/botorch/models/gpytorch.html
@@ -588,7 +588,9 @@ Source code for botorch.models.gpytorch
subset_batch_dict = self._subset_batch_dict
except AttributeError:
raise NotImplementedError(
- "subset_output requires the model to define a `_subset_dict` attribute"
+ "`subset_output` requires the model to define a `_subset_batch_dict` "
+ "attribute that lists the indices of the output dimensions in each "
+ "model parameter that needs to be subset."
)
m = len(idcs)
diff --git a/v/latest/api/_modules/botorch/models/gpytorch/index.html b/v/latest/api/_modules/botorch/models/gpytorch/index.html
index 9b22251c80..f01de465a9 100644
--- a/v/latest/api/_modules/botorch/models/gpytorch/index.html
+++ b/v/latest/api/_modules/botorch/models/gpytorch/index.html
@@ -588,7 +588,9 @@ Source code for botorch.models.gpytorch
subset_batch_dict = self._subset_batch_dict
except AttributeError:
raise NotImplementedError(
- "subset_output requires the model to define a `_subset_dict` attribute"
+ "`subset_output` requires the model to define a `_subset_batch_dict` "
+ "attribute that lists the indices of the output dimensions in each "
+ "model parameter that needs to be subset."
)
m = len(idcs)
diff --git a/v/latest/api/_modules/botorch/models/kernels/contextual_lcea.html b/v/latest/api/_modules/botorch/models/kernels/contextual_lcea.html
index 8e72dd31ab..a9d47bef33 100644
--- a/v/latest/api/_modules/botorch/models/kernels/contextual_lcea.html
+++ b/v/latest/api/_modules/botorch/models/kernels/contextual_lcea.html
@@ -30,9 +30,9 @@ Source code for botorch.models.kernels.contextual_lcea
from typing import Any, Optional
import torch
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from gpytorch.constraints import Positive
from gpytorch.kernels.kernel import Kernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.priors.torch_priors import GammaPrior
from linear_operator.operators import DiagLinearOperator
from linear_operator.operators.dense_linear_operator import DenseLinearOperator
@@ -183,18 +183,14 @@ Source code for botorch.models.kernels.contextual_lcea
if train_embedding:
self._set_emb_layers()
# task covariance matrix
- self.task_covar_module = MaternKernel(
- nu=2.5,
+ self.task_covar_module = get_covar_module_with_dim_scaled_prior(
ard_num_dims=self.n_embs,
batch_shape=batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
)
# base kernel
- self.base_kernel = MaternKernel(
- nu=2.5,
+ self.base_kernel = get_covar_module_with_dim_scaled_prior(
ard_num_dims=self.num_param,
batch_shape=batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
)
# outputscales for each context (note this is like sqrt of outputscale)
self.context_weight = None
diff --git a/v/latest/api/_modules/botorch/models/kernels/contextual_lcea/index.html b/v/latest/api/_modules/botorch/models/kernels/contextual_lcea/index.html
index 8e72dd31ab..a9d47bef33 100644
--- a/v/latest/api/_modules/botorch/models/kernels/contextual_lcea/index.html
+++ b/v/latest/api/_modules/botorch/models/kernels/contextual_lcea/index.html
@@ -30,9 +30,9 @@ Source code for botorch.models.kernels.contextual_lcea
from typing import Any, Optional
import torch
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from gpytorch.constraints import Positive
from gpytorch.kernels.kernel import Kernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.priors.torch_priors import GammaPrior
from linear_operator.operators import DiagLinearOperator
from linear_operator.operators.dense_linear_operator import DenseLinearOperator
@@ -183,18 +183,14 @@ Source code for botorch.models.kernels.contextual_lcea
if train_embedding:
self._set_emb_layers()
# task covariance matrix
- self.task_covar_module = MaternKernel(
- nu=2.5,
+ self.task_covar_module = get_covar_module_with_dim_scaled_prior(
ard_num_dims=self.n_embs,
batch_shape=batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
)
# base kernel
- self.base_kernel = MaternKernel(
- nu=2.5,
+ self.base_kernel = get_covar_module_with_dim_scaled_prior(
ard_num_dims=self.num_param,
batch_shape=batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
)
# outputscales for each context (note this is like sqrt of outputscale)
self.context_weight = None
diff --git a/v/latest/api/_modules/botorch/models/kernels/contextual_sac.html b/v/latest/api/_modules/botorch/models/kernels/contextual_sac.html
index b0dd07e859..8e296623ca 100644
--- a/v/latest/api/_modules/botorch/models/kernels/contextual_sac.html
+++ b/v/latest/api/_modules/botorch/models/kernels/contextual_sac.html
@@ -30,8 +30,8 @@ Source code for botorch.models.kernels.contextual_sac
from typing import Any, Optional
import torch
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from gpytorch.kernels.kernel import Kernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.kernels.scale_kernel import ScaleKernel
from gpytorch.priors.torch_priors import GammaPrior
from linear_operator.operators.sum_linear_operator import SumLinearOperator
@@ -61,7 +61,7 @@ Source code for botorch.models.kernels.contextual_sac
where
* :math: M is the number of partitions of parameter space. Each partition contains
same number of parameters d. Each kernel `k_i` acts only on d parameters of ith
- partition i.e. `\mathbf{x}_(i)`. Each kernel `k_i` is a scaled Matern kernel
+ partition i.e. `\mathbf{x}_(i)`. Each kernel `k_i` is a scaled RBF kernel
with same lengthscales but different outputscales.
"""
@@ -97,11 +97,9 @@ Source code for botorch.models.kernels.contextual_sac
for context, active_params in self.decomposition.items()
}
- self.base_kernel = MaternKernel(
- nu=2.5,
+ self.base_kernel = get_covar_module_with_dim_scaled_prior(
ard_num_dims=num_param,
batch_shape=batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
)
self.kernel_dict = {} # scaled kernel for each parameter space partition
diff --git a/v/latest/api/_modules/botorch/models/kernels/contextual_sac/index.html b/v/latest/api/_modules/botorch/models/kernels/contextual_sac/index.html
index b0dd07e859..8e296623ca 100644
--- a/v/latest/api/_modules/botorch/models/kernels/contextual_sac/index.html
+++ b/v/latest/api/_modules/botorch/models/kernels/contextual_sac/index.html
@@ -30,8 +30,8 @@ Source code for botorch.models.kernels.contextual_sac
from typing import Any, Optional
import torch
+from botorch.models.utils.gpytorch_modules import get_covar_module_with_dim_scaled_prior
from gpytorch.kernels.kernel import Kernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.kernels.scale_kernel import ScaleKernel
from gpytorch.priors.torch_priors import GammaPrior
from linear_operator.operators.sum_linear_operator import SumLinearOperator
@@ -61,7 +61,7 @@ Source code for botorch.models.kernels.contextual_sac
where
* :math: M is the number of partitions of parameter space. Each partition contains
same number of parameters d. Each kernel `k_i` acts only on d parameters of ith
- partition i.e. `\mathbf{x}_(i)`. Each kernel `k_i` is a scaled Matern kernel
+ partition i.e. `\mathbf{x}_(i)`. Each kernel `k_i` is a scaled RBF kernel
with same lengthscales but different outputscales.
"""
@@ -97,11 +97,9 @@ Source code for botorch.models.kernels.contextual_sac
for context, active_params in self.decomposition.items()
}
- self.base_kernel = MaternKernel(
- nu=2.5,
+ self.base_kernel = get_covar_module_with_dim_scaled_prior(
ard_num_dims=num_param,
batch_shape=batch_shape,
- lengthscale_prior=GammaPrior(3.0, 6.0),
)
self.kernel_dict = {} # scaled kernel for each parameter space partition
diff --git a/v/latest/api/_modules/botorch/models/multitask.html b/v/latest/api/_modules/botorch/models/multitask.html
index 0a93b69969..6c5c429d77 100644
--- a/v/latest/api/_modules/botorch/models/multitask.html
+++ b/v/latest/api/_modules/botorch/models/multitask.html
@@ -63,7 +63,8 @@ Source code for botorch.models.multitask
from botorch.models.transforms.input import InputTransform
from botorch.models.transforms.outcome import OutcomeTransform
from botorch.models.utils.gpytorch_modules import (
- get_matern_kernel_with_gamma_prior,
+ get_covar_module_with_dim_scaled_prior,
+ get_gaussian_likelihood_with_lognormal_prior,
MIN_INFERRED_NOISE_LEVEL,
)
from botorch.posteriors.multitask import MultitaskGPPosterior
@@ -74,12 +75,8 @@ Source code for botorch.models.multitask
)
from gpytorch.distributions.multivariate_normal import MultivariateNormal
from gpytorch.kernels.index_kernel import IndexKernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.kernels.multitask_kernel import MultitaskKernel
-from gpytorch.likelihoods.gaussian_likelihood import (
- FixedNoiseGaussianLikelihood,
- GaussianLikelihood,
-)
+from gpytorch.likelihoods.gaussian_likelihood import FixedNoiseGaussianLikelihood
from gpytorch.likelihoods.likelihood import Likelihood
from gpytorch.likelihoods.multitask_gaussian_likelihood import (
MultitaskGaussianLikelihood,
@@ -195,7 +192,7 @@ Source code for botorch.models.multitask
Note that the inferred noise is common across all tasks.
mean_module: The mean function to be used. Defaults to `ConstantMean`.
covar_module: The module for computing the covariance matrix between
- the non-task features. Defaults to `MaternKernel`.
+ the non-task features. Defaults to `RBFKernel`.
likelihood: A likelihood. The default is selected based on `train_Yvar`.
If `train_Yvar` is None, a standard `GaussianLikelihood` with inferred
noise level is used. Otherwise, a FixedNoiseGaussianLikelihood is used.
@@ -261,7 +258,7 @@ Source code for botorch.models.multitask
# TODO (T41270962): Support task-specific noise levels in likelihood
if likelihood is None:
if train_Yvar is None:
- likelihood = GaussianLikelihood(noise_prior=GammaPrior(1.1, 0.05))
+ likelihood = get_gaussian_likelihood_with_lognormal_prior()
else:
likelihood = FixedNoiseGaussianLikelihood(noise=train_Yvar.squeeze(-1))
@@ -275,7 +272,7 @@ Source code for botorch.models.multitask
)
self.mean_module = mean_module or ConstantMean()
if covar_module is None:
- self.covar_module = get_matern_kernel_with_gamma_prior(
+ self.covar_module = get_covar_module_with_dim_scaled_prior(
ard_num_dims=self.num_non_task_features
)
else:
@@ -482,7 +479,7 @@ Source code for botorch.models.multitask
`MultitaskGaussianLikelihood` with a `GammaPrior(1.1, 0.05)`
noise prior.
data_covar_module: The module computing the covariance (Kernel) matrix
- in data space. If omitted, use a `MaternKernel`.
+ in data space. If omitted, uses an `RBFKernel`.
task_covar_prior : A Prior on the task covariance matrix. Must operate
on p.s.d. matrices. A common prior for this is the `LKJ` prior. If
omitted, uses `LKJCovariancePrior` with `eta` parameter as specified
@@ -540,10 +537,8 @@ Source code for botorch.models.multitask
base_means=ConstantMean(batch_shape=batch_shape), num_tasks=num_tasks
)
if data_covar_module is None:
- data_covar_module = MaternKernel(
- nu=2.5,
+ data_covar_module = get_covar_module_with_dim_scaled_prior(
ard_num_dims=ard_num_dims,
- lengthscale_prior=GammaPrior(3.0, 6.0),
batch_shape=batch_shape,
)
else:
diff --git a/v/latest/api/_modules/botorch/models/multitask/index.html b/v/latest/api/_modules/botorch/models/multitask/index.html
index 0a93b69969..6c5c429d77 100644
--- a/v/latest/api/_modules/botorch/models/multitask/index.html
+++ b/v/latest/api/_modules/botorch/models/multitask/index.html
@@ -63,7 +63,8 @@ Source code for botorch.models.multitask
from botorch.models.transforms.input import InputTransform
from botorch.models.transforms.outcome import OutcomeTransform
from botorch.models.utils.gpytorch_modules import (
- get_matern_kernel_with_gamma_prior,
+ get_covar_module_with_dim_scaled_prior,
+ get_gaussian_likelihood_with_lognormal_prior,
MIN_INFERRED_NOISE_LEVEL,
)
from botorch.posteriors.multitask import MultitaskGPPosterior
@@ -74,12 +75,8 @@ Source code for botorch.models.multitask
)
from gpytorch.distributions.multivariate_normal import MultivariateNormal
from gpytorch.kernels.index_kernel import IndexKernel
-from gpytorch.kernels.matern_kernel import MaternKernel
from gpytorch.kernels.multitask_kernel import MultitaskKernel
-from gpytorch.likelihoods.gaussian_likelihood import (
- FixedNoiseGaussianLikelihood,
- GaussianLikelihood,
-)
+from gpytorch.likelihoods.gaussian_likelihood import FixedNoiseGaussianLikelihood
from gpytorch.likelihoods.likelihood import Likelihood
from gpytorch.likelihoods.multitask_gaussian_likelihood import (
MultitaskGaussianLikelihood,
@@ -195,7 +192,7 @@ Source code for botorch.models.multitask
Note that the inferred noise is common across all tasks.
mean_module: The mean function to be used. Defaults to `ConstantMean`.
covar_module: The module for computing the covariance matrix between
- the non-task features. Defaults to `MaternKernel`.
+ the non-task features. Defaults to `RBFKernel`.
likelihood: A likelihood. The default is selected based on `train_Yvar`.
If `train_Yvar` is None, a standard `GaussianLikelihood` with inferred
noise level is used. Otherwise, a FixedNoiseGaussianLikelihood is used.
@@ -261,7 +258,7 @@ Source code for botorch.models.multitask
# TODO (T41270962): Support task-specific noise levels in likelihood
if likelihood is None:
if train_Yvar is None:
- likelihood = GaussianLikelihood(noise_prior=GammaPrior(1.1, 0.05))
+ likelihood = get_gaussian_likelihood_with_lognormal_prior()
else:
likelihood = FixedNoiseGaussianLikelihood(noise=train_Yvar.squeeze(-1))
@@ -275,7 +272,7 @@ Source code for botorch.models.multitask
)
self.mean_module = mean_module or ConstantMean()
if covar_module is None:
- self.covar_module = get_matern_kernel_with_gamma_prior(
+ self.covar_module = get_covar_module_with_dim_scaled_prior(
ard_num_dims=self.num_non_task_features
)
else:
@@ -482,7 +479,7 @@ Source code for botorch.models.multitask
`MultitaskGaussianLikelihood` with a `GammaPrior(1.1, 0.05)`
noise prior.
data_covar_module: The module computing the covariance (Kernel) matrix
- in data space. If omitted, use a `MaternKernel`.
+ in data space. If omitted, uses an `RBFKernel`.
task_covar_prior : A Prior on the task covariance matrix. Must operate
on p.s.d. matrices. A common prior for this is the `LKJ` prior. If
omitted, uses `LKJCovariancePrior` with `eta` parameter as specified
@@ -540,10 +537,8 @@ Source code for botorch.models.multitask
base_means=ConstantMean(batch_shape=batch_shape), num_tasks=num_tasks
)
if data_covar_module is None:
- data_covar_module = MaternKernel(
- nu=2.5,
+ data_covar_module = get_covar_module_with_dim_scaled_prior(
ard_num_dims=ard_num_dims,
- lengthscale_prior=GammaPrior(3.0, 6.0),
batch_shape=batch_shape,
)
else:
diff --git a/v/latest/api/_modules/botorch/models/utils/gpytorch_modules.html b/v/latest/api/_modules/botorch/models/utils/gpytorch_modules.html
index 314707855f..a988632b3d 100644
--- a/v/latest/api/_modules/botorch/models/utils/gpytorch_modules.html
+++ b/v/latest/api/_modules/botorch/models/utils/gpytorch_modules.html
@@ -41,7 +41,7 @@ Source code for botorch.models.utils.gpytorch_modules
"""
from math import log, sqrt
-from typing import Optional, Union
+from typing import Optional, Sequence, Union
import torch
from gpytorch.constraints.constraints import GreaterThan
@@ -135,7 +135,8 @@ Source code for botorch.models.utils.gpytorch_modules
ard_num_dims: int,
batch_shape: Optional[torch.Size] = None,
use_rbf_kernel: bool = True,
-) -> Union[MaternKernel, RBFKernel, ScaleKernel]:
+ active_dims: Optional[Sequence[int]] = None,
+) -> Union[MaternKernel, RBFKernel]:
"""Returns an RBF or Matern kernel with priors
from [Hvarfner2024vanilla]_.
@@ -143,6 +144,9 @@ Source code for botorch.models.utils.gpytorch_modules
ard_num_dims: Number of feature dimensions for ARD.
batch_shape: Batch shape for the covariance module.
use_rbf_kernel: Whether to use an RBF kernel. If False, uses a Matern kernel.
+ active_dims: The set of input dimensions to compute the covariances on.
+ By default, the covariance is computed using the full input tensor.
+ Set this if you'd like to ignore certain dimensions.
Returns:
A Kernel constructed according to the given arguments. The prior is constrained
@@ -157,6 +161,8 @@ Source code for botorch.models.utils.gpytorch_modules
lengthscale_constraint=GreaterThan(
2.5e-2, transform=None, initial_value=lengthscale_prior.mode
),
+ # pyre-ignore[6] GPyTorch type is unnecessarily restrictive.
+ active_dims=active_dims,
)
return base_kernel
diff --git a/v/latest/api/_modules/botorch/models/utils/gpytorch_modules/index.html b/v/latest/api/_modules/botorch/models/utils/gpytorch_modules/index.html
index 314707855f..a988632b3d 100644
--- a/v/latest/api/_modules/botorch/models/utils/gpytorch_modules/index.html
+++ b/v/latest/api/_modules/botorch/models/utils/gpytorch_modules/index.html
@@ -41,7 +41,7 @@ Source code for botorch.models.utils.gpytorch_modules
"""
from math import log, sqrt
-from typing import Optional, Union
+from typing import Optional, Sequence, Union
import torch
from gpytorch.constraints.constraints import GreaterThan
@@ -135,7 +135,8 @@ Source code for botorch.models.utils.gpytorch_modules
ard_num_dims: int,
batch_shape: Optional[torch.Size] = None,
use_rbf_kernel: bool = True,
-) -> Union[MaternKernel, RBFKernel, ScaleKernel]:
+ active_dims: Optional[Sequence[int]] = None,
+) -> Union[MaternKernel, RBFKernel]:
"""Returns an RBF or Matern kernel with priors
from [Hvarfner2024vanilla]_.
@@ -143,6 +144,9 @@ Source code for botorch.models.utils.gpytorch_modules
ard_num_dims: Number of feature dimensions for ARD.
batch_shape: Batch shape for the covariance module.
use_rbf_kernel: Whether to use an RBF kernel. If False, uses a Matern kernel.
+ active_dims: The set of input dimensions to compute the covariances on.
+ By default, the covariance is computed using the full input tensor.
+ Set this if you'd like to ignore certain dimensions.
Returns:
A Kernel constructed according to the given arguments. The prior is constrained
@@ -157,6 +161,8 @@ Source code for botorch.models.utils.gpytorch_modules
lengthscale_constraint=GreaterThan(
2.5e-2, transform=None, initial_value=lengthscale_prior.mode
),
+ # pyre-ignore[6] GPyTorch type is unnecessarily restrictive.
+ active_dims=active_dims,
)
return base_kernel
diff --git a/v/latest/api/models.html b/v/latest/api/models.html
index 5157ceb3e6..a6745b91a4 100644
--- a/v/latest/api/models.html
+++ b/v/latest/api/models.html
@@ -1452,7 +1452,7 @@ Models¶
is None, and a FixedNoiseGaussianLikelihood with the given
noise observations if train_Yvar is not None.
covar_module (Optional[Module]) – The module computing the covariance (Kernel) matrix.
-If omitted, use a MaternKernel.
+If omitted, uses an RBFKernel.
mean_module (Optional[Mean]) – The mean function to be used. If omitted, use a
ConstantMean.
outcome_transform (Optional[Union[OutcomeTransform, _DefaultType]]) – An outcome transform that is applied to the
@@ -1807,7 +1807,7 @@
Models¶
cont_kernel_factory (Optional[Callable[[torch.Size, int, list[int]], Kernel]]) – A method that accepts batch_shape, ard_num_dims,
and active_dims arguments and returns an instantiated GPyTorch
Kernel object to be used as the base kernel for the continuous
-dimensions. If omitted, this model uses a Matern-2.5 kernel as
+dimensions. If omitted, this model uses an RBFKernel as
the kernel for the ordinal parameters.
likelihood (Optional[Likelihood]) – A likelihood. If omitted, use a standard
GaussianLikelihood with inferred noise level.
@@ -1995,7 +1995,7 @@ Models¶
Note that the inferred noise is common across all tasks.
mean_module (Optional[Module]) – The mean function to be used. Defaults to ConstantMean.
covar_module (Optional[Module]) – The module for computing the covariance matrix between
-the non-task features. Defaults to MaternKernel.
+the non-task features. Defaults to RBFKernel.
likelihood (Optional[Likelihood]) – A likelihood. The default is selected based on train_Yvar.
If train_Yvar is None, a standard GaussianLikelihood with inferred
noise level is used. Otherwise, a FixedNoiseGaussianLikelihood is used.
@@ -2131,7 +2131,7 @@ Models¶
MultitaskGaussianLikelihood with a GammaPrior(1.1, 0.05)
noise prior.
data_covar_module (Optional[Module]) – The module computing the covariance (Kernel) matrix
-in data space. If omitted, use a MaternKernel.
+in data space. If omitted, uses an RBFKernel.
task_covar_prior (Optional[Prior]) – A Prior on the task covariance matrix. Must operate
on p.s.d. matrices. A common prior for this is the LKJ prior. If
omitted, uses LKJCovariancePrior with eta parameter as specified
@@ -2914,7 +2914,7 @@
Models¶
is common across all tasks.
mean_module (Module | None) – The mean function to be used. Defaults to ConstantMean.
covar_module (Module | None) – The module for computing the covariance matrix between
-the non-task features. Defaults to MaternKernel.
+the non-task features. Defaults to RBFKernel.
likelihood (Likelihood | None) – A likelihood. The default is selected based on train_Yvar.
If train_Yvar is None, a standard GaussianLikelihood with inferred
noise level is used. Otherwise, a FixedNoiseGaussianLikelihood is used.
@@ -3198,7 +3198,7 @@ Models¶
either a GaussianLikelihood (if num_outputs=1) or a
MultitaskGaussianLikelihood`(if `num_outputs>1).
num_outputs (int) – Number of output responses per input (default: 1).
-covar_module (Optional[Kernel]) – Kernel function. If omitted, uses a MaternKernel.
+covar_module (Optional[Kernel]) – Kernel function. If omitted, uses an RBFKernel.
mean_module (Optional[Mean]) – Mean of GP model. If omitted, uses a ConstantMean.
variational_distribution (Optional[_VariationalDistribution]) – Type of variational distribution to use
(default: CholeskyVariationalDistribution), the properties of the
@@ -4251,7 +4251,7 @@
Model Components
Parameters:
@@ -6448,7 +6448,7 @@ Utilities
-botorch.models.utils.gpytorch_modules.get_covar_module_with_dim_scaled_prior(ard_num_dims, batch_shape=None, use_rbf_kernel=True)[source]¶
+botorch.models.utils.gpytorch_modules.get_covar_module_with_dim_scaled_prior(ard_num_dims, batch_shape=None, use_rbf_kernel=True, active_dims=None)[source]¶
Returns an RBF or Matern kernel with priors
from [Hvarfner2024vanilla].
diff --git a/v/latest/api/models/index.html b/v/latest/api/models/index.html
index 5157ceb3e6..a6745b91a4 100644
--- a/v/latest/api/models/index.html
+++ b/v/latest/api/models/index.html
@@ -1452,7 +1452,7 @@ Models¶
is None, and a FixedNoiseGaussianLikelihood with the given
noise observations if train_Yvar is not None.
covar_module (Optional[Module]) – The module computing the covariance (Kernel) matrix.
-If omitted, use a MaternKernel.
+If omitted, uses an RBFKernel.
mean_module (Optional[Mean]) – The mean function to be used. If omitted, use a
ConstantMean.
outcome_transform (Optional[Union[OutcomeTransform, _DefaultType]]) – An outcome transform that is applied to the
@@ -1807,7 +1807,7 @@
Models¶
cont_kernel_factory (Optional[Callable[[torch.Size, int, list[int]], Kernel]]) – A method that accepts batch_shape, ard_num_dims,
and active_dims arguments and returns an instantiated GPyTorch
Kernel object to be used as the base kernel for the continuous
-dimensions. If omitted, this model uses a Matern-2.5 kernel as
+dimensions. If omitted, this model uses an RBFKernel as
the kernel for the ordinal parameters.
likelihood (Optional[Likelihood]) – A likelihood. If omitted, use a standard
GaussianLikelihood with inferred noise level.
@@ -1995,7 +1995,7 @@ Models¶
Note that the inferred noise is common across all tasks.
mean_module (Optional[Module]) – The mean function to be used. Defaults to ConstantMean.
covar_module (Optional[Module]) – The module for computing the covariance matrix between
-the non-task features. Defaults to MaternKernel.
+the non-task features. Defaults to RBFKernel.
likelihood (Optional[Likelihood]) – A likelihood. The default is selected based on train_Yvar.
If train_Yvar is None, a standard GaussianLikelihood with inferred
noise level is used. Otherwise, a FixedNoiseGaussianLikelihood is used.
@@ -2131,7 +2131,7 @@ Models¶
MultitaskGaussianLikelihood with a GammaPrior(1.1, 0.05)
noise prior.
data_covar_module (Optional[Module]) – The module computing the covariance (Kernel) matrix
-in data space. If omitted, use a MaternKernel.
+in data space. If omitted, uses an RBFKernel.
task_covar_prior (Optional[Prior]) – A Prior on the task covariance matrix. Must operate
on p.s.d. matrices. A common prior for this is the LKJ prior. If
omitted, uses LKJCovariancePrior with eta parameter as specified
@@ -2914,7 +2914,7 @@
Models¶
is common across all tasks.
mean_module (Module | None) – The mean function to be used. Defaults to ConstantMean.
covar_module (Module | None) – The module for computing the covariance matrix between
-the non-task features. Defaults to MaternKernel.
+the non-task features. Defaults to RBFKernel.
likelihood (Likelihood | None) – A likelihood. The default is selected based on train_Yvar.
If train_Yvar is None, a standard GaussianLikelihood with inferred
noise level is used. Otherwise, a FixedNoiseGaussianLikelihood is used.
@@ -3198,7 +3198,7 @@ Models¶
either a GaussianLikelihood (if num_outputs=1) or a
MultitaskGaussianLikelihood`(if `num_outputs>1).
num_outputs (int) – Number of output responses per input (default: 1).
-covar_module (Optional[Kernel]) – Kernel function. If omitted, uses a MaternKernel.
+covar_module (Optional[Kernel]) – Kernel function. If omitted, uses an RBFKernel.
mean_module (Optional[Mean]) – Mean of GP model. If omitted, uses a ConstantMean.
variational_distribution (Optional[_VariationalDistribution]) – Type of variational distribution to use
(default: CholeskyVariationalDistribution), the properties of the
@@ -4251,7 +4251,7 @@
Model Components
Parameters:
@@ -6448,7 +6448,7 @@ Utilities
-botorch.models.utils.gpytorch_modules.get_covar_module_with_dim_scaled_prior(ard_num_dims, batch_shape=None, use_rbf_kernel=True)[source]¶
+botorch.models.utils.gpytorch_modules.get_covar_module_with_dim_scaled_prior(ard_num_dims, batch_shape=None, use_rbf_kernel=True, active_dims=None)[source]¶
Returns an RBF or Matern kernel with priors
from [Hvarfner2024vanilla].
diff --git a/v/latest/docs/models.html b/v/latest/docs/models.html
index d479314ac3..c5343f4564 100644
--- a/v/latest/docs/models.html
+++ b/v/latest/docs/models.html
@@ -171,10 +171,14 @@ this discussion for
+additional context on the default hyperparameters.
Other useful models
ModelList
: a
@@ -227,7 +231,7 @@
If you happen to implement a model that would be useful for other researchers as
-well (and involves more than just swapping out the Matérn kernel for an RBF
+well (and involves more than just swapping out the RBF kernel for a Matérn
kernel), please consider contributing this model
to BoTorch.