cornellius-gp / gpytorch

A highly efficient implementation of Gaussian Processes in PyTorch
MIT License
3.54k stars 557 forks source link

Hi, I have a question about how to set the parameter of the kernel. #2364

Closed findoctorlin closed 1 year ago

findoctorlin commented 1 year ago

Hi, I have a question about how to set the parameter of the kernel. For example, if I know the lengthscale in RBFKernel and I do not need to train the kernel, how can I set the parameter? Thank you for your help!

Originally posted by @HanyangHenry-Wang in https://github.com/cornellius-gp/gpytorch/discussions/2238

Thank you! Looks like it can make the "lengthscale shape" of kernel being stable during the training, is it true that the final shape of the underlying function is defined by the final kernel we trained? Like if we get a trained kernel after training process, we use the likelihood function to do prediction as shown in the DGP demo code.

gpleiss commented 1 year ago
self.covar_module.base_kernel.lengthscale = 2
self.covar_module.base_kernel.raw_lengthscale.requires_grad_(False)

Thank you! Looks like it can make the "lengthscale shape" of kernel being stable during the training, is it true that the final shape of the underlying function is defined by the final kernel we trained? Like if we get a trained kernel after training process, we use the likelihood function to do prediction as shown in the DGP demo code.

I'm not sure what you mean by "shape." Do you mean the dimensions of the lengthscale parameter tensor? This does not change during training or prediction.

gpleiss commented 1 year ago

In the future, please open these questions as a discussion, as they are not bugs/feature requests with the library.