correction of a bug in gauss kernel computation
This commit is contained in:
parent
97412812bd
commit
cee77bc88c
|
@ -8,7 +8,7 @@ function(X1, X2, sigma2)
|
|||
K <- matrix(nrow = n1, ncol = n2)
|
||||
for(i in 1:n1)
|
||||
for(j in 1:n2)
|
||||
K[i,j] <- sum(X1[i,] - X2[j,])^2
|
||||
K[i,j] <- sum((X1[i,] - X2[j,])^2)
|
||||
K <- exp(-1*K/sigma2)
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,8 @@ function(X, y, sigma2=NULL, lambda=1E-4, landmarks=NULL, nb.landmarks=NULL)
|
|||
|
||||
svdK11 <- svd(K11)
|
||||
# K11 will often be ill-formed, thus we drop the bottom singular values
|
||||
k <- which(svdK11$d < 1E-12)[1] - 1
|
||||
ks <- which(svdK11$d < 1E-12)
|
||||
if (length(ks)>0) {k <- ks[1]} else {k <- length(svdK11$d)}
|
||||
|
||||
US <- svdK11$u[,1:k] %*% diag(1 / sqrt(svdK11$d[1:k]))
|
||||
L <- C %*% US
|
||||
|
|
Loading…
Reference in New Issue