aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2018-03-27 19:24:03 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2018-03-27 19:24:03 +0100
commitd83e911fe228571171f9ddc379708dc37c4bfddf (patch)
treefc396f91eaf92010ef0db33e0bb3b084e69402ac /src
parentupdate training file for zip dataset (diff)
downloadgensvm-d83e911fe228571171f9ddc379708dc37c4bfddf.tar.gz
gensvm-d83e911fe228571171f9ddc379708dc37c4bfddf.zip
Major bugfix for nonlinear GenSVM
Nonlinear GenSVM depends on the eigendecomposition of the kernel matrix. Mathematically, the Sigma vector in the code should contain the square root of the eigenvalues. Taking the square root was however neglected, which resulted in poor performance of nonlinear GenSVM. This is now fixed, which means that the performance of nonlinear GenSVM will be much better.
Diffstat (limited to 'src')
-rw-r--r--src/gensvm_kernel.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gensvm_kernel.c b/src/gensvm_kernel.c
index 521bddb..190a120 100644
--- a/src/gensvm_kernel.c
+++ b/src/gensvm_kernel.c
@@ -264,9 +264,12 @@ long gensvm_kernel_eigendecomp(double *K, long n, double cutoff, double **P_ret,
num_eigen = n - cutoff_idx;
+ // In the mathematical derivation (see paper), we state that the
+ // diagonal matrix Sigma contains the square root of the eigenvalues
+ // (i.e. the eigendecomposition is: K = P * Sigma^2 * P').
Sigma = Calloc(double, num_eigen);
for (i=0; i<num_eigen; i++) {
- Sigma[i] = tempSigma[n-1 - i];
+ Sigma[i] = sqrt(tempSigma[n-1 - i]);
}
// revert P to row-major order and copy only the the columns