I am using GPyTorch regressor according to the documentation.
I would like to set an initial value for the "lengthscale" hyperparameter in RBF kernel.
I want to set a constant number as initial value for "lengthscale" (similar to what we can do in scikit-learn Gaussian Process Regressor).
If you have any idea, please let me know.
There are two cases that follow from your question:
You want to initialize your lengthscale with some value but the lengthscale is then optimized on further by the optimizer
Assuming you have the same model as given in the documentation you have linked, just add the following before your training loop:
The
model.covar_module
gets your entire kernel and thebase_kernel
gets you your RBF kernel.You want to fix your lengthscale as some constant value which will not be further optimized
In addition to the code for the first case, you do not feed the lengthscale as a hyperparameter to be optimized to your optimizer.
We remove the set of raw lengthscale values from
all_params
to createfinal_params
which we then pass to the optimizer.Some sources to help: