Skip to content

Combining kernel functions together #1278

Answered by wjmaddox
ovr4 asked this question in Q&A
Discussion options

You must be logged in to vote

This can be done natively in gpytorch, so an example that's integrated in Botorch is

from botorch.models import SingleTaskGP
from gpytorch.kernels import MaternKernel, RBFKernel, IndexKernel

train_x = torch.randn(40, 6)
train_x[train_x[:,-1] >0] = 1
train_x[train_x[:,-1] < 0] = 0
# the active dims argument sets the dimensions used for each kernel
# Edit: note that the IndexKernel requires a num_tasks argument -- we have two tasks here
covar_module = MaternKernel(active_dims=[0]) + RBFKernel(active_dims=[1,2,3,4]) + IndexKernel(num_tasks=2, active_dims=5)

train_y = torch.randn(40, 1) # some data

model = SingleTaskGP(train_x, train_y, covar_module=covar_module)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by saitcakmak
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #979 on June 29, 2022 22:21.