我正在尝试以下内核:
class AperiodicMatern12(gpflow.kernels.Kernel):
def __init__(self, input_dim = None, period = 1.0, variance = 1.0,
lengthscales = 1.0, active_dims = None, name = None):
super().init(input_dim, active_dims = active_dims)
k0 = gpflow.kernels.Matern12(input_dim, active_dims = active_dims)
k1 = gpflow.kernels.Matern12(input_dim, active_dims = active_dims)
k = gpflow.kernels.Periodic(base = k1, period = period)
self.base = k0
self.per = k
@gpflow.params_as_tensors
def K(self, X, X2 = None):
res = self.base.K(X, X2) - self.per.K(X, X2)
return res
def Kdiag(self, X):
return np.diag(self.K(X))
当我运行它时:
lik = gpflow.likelihoods.Gaussian()
k = AperiodicMatern12(1, active_dims = [0])
m = gpflow.models.GPR(X, Y, kern = k)
gpflow.train.ScipyOptimizer().minimize(m)
我得到:
InvalidArgumentError(参见上文的追溯):Cholesky 分解不成功。输入可能无效。[[节点 GPR-0b2840db-15/likelihood_1/Cholesky(定义在 /Users/mjg/anaconda3/lib/python3.6/site-packages/gpflow/models/gpr.py:72)]]
当我尝试使用定义为添加剂的内核时:
@gpflow.params_as_tensors
def K(self, X, X2 = None):
res = self.base.K(X, X2) + self.per.K(X, X2)
return res
一切正常。X 和 Y 在这两种情况下都是标准化的。那么减法内核有什么问题呢?