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

Any way to use combination of multiple kernels ? #2

Open
pranav997 opened this issue Mar 13, 2023 · 3 comments
Open

Any way to use combination of multiple kernels ? #2

pranav997 opened this issue Mar 13, 2023 · 3 comments

Comments

@pranav997
Copy link

Hi,
Thanks very much for this code implementation. I was wondering if there is any way to use combination of different kernels like (Krbf*Kmatern+Krbf) within the same code ??

@brunzema
Copy link
Owner

Hi,
The code is part of our paper, where we use a product kernel as k_RBF * k_Wiener, where only the RBF kernel is constrained; thus combinations of different kernels are possible, if the other kernels should not be constrained. Then you can simply define the self.covar_module as:

self.spatio_kernel = gpytorch.kernels.ScaleKernel(
RBFKernelForConvexityConstraints(constrained_dims=constrained_dims,
                                 ard_num_dims=self.spatio_dims,
                                 active_dims=range(self.spatio_dims),
                                 lengthscale_prior=lengthscale_hyperprior,
                                 lengthscale_constraint=lengthscale_constraint),
...
self.covar_module = self.spatio_kernel * MaternKernel(...) + RBFKernel(...)

This way, your first RBF kernel is constrained and the others are not. Unfortunately, all the derivatives of the kernels are all hardcoded. If you want a constrained Matern kernel you would have to do this as well...

@pranav997
Copy link
Author

Thanks for your response. I was wondering if there is a way to put data dependent constraints on function. I have a four dimensional function x=[x1,x2,x3,x4]. I would want to put constraints such as f(x2)>f(x'2) for x2>x'2. I also want to put bound constraints which are data dependent such as f(x1)<x1 for different values of x1. Is there any way to do that with your code?

@brunzema
Copy link
Owner

No, unfortunately, monotonicity constraints as well as bounds on the predictions are currently not implemented. One can however extend the code to do this. I would suggest to first look at the repo of Agrell (2019) (here) and then reimplement the stacking of matricies using this code base. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants