Open pranav997 opened 1 year ago
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...
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?
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. :)
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 ??