How to add "ARD" in gpflow.kernels.RBF()

88 views Asked by At

Regarding documents of GPFlow2.8.1, It looks there is no way to use ARD in gpflow.kernels.RBF(SquaredExponential). Is it not possible to add ARD settings in RBF?

Following are the current code.(I use gpflow in Trisete)

kernel = gpflow.kernels.RBF()
gpr = gpflow.models.GPR((past_query_points, past_observations), kernel)
gpflow.set_trainable(gpr.likelihood, True)
gpr.likelihood.variance.assign(1e-5)
model = GaussianProcessRegression(gpr)
print("Before optimize hyperparameters of GPR")
gpflow.utilities.print_summary(gpr)
model.optimize(dataset)
print("After optimize hyperparameters of GPR")
gpflow.utilities.print_summary(gpr)

I tried kernel = gpflow.kernels.RBF(ARD=TRUE) but it was error.

1

There are 1 answers

0
LePe77it On

In gpflow 2.9.0, you just add two args and a single **kwargs:

  • variance = ... (your choice);
  • lengthscales = a np.array with your regressor vector's dimensions;
  • active_dims = a list with the dimensions you what to estimate a different hyperparameter.

Check this.

Here is an example:

gpflow.kernels.SquaredExponential(variance=np.array('your variance guess'),
                                       lengthscales=np.random.rand('your regressor vector'.shape[1]),
                                      active_dims=list(m for m in range('your regressor vector'.shape[1])))

In this code, I activated the ARD for all dimensions.