diff options
| author | Gertjan van den Burg <burg@ese.eur.nl> | 2014-03-21 16:09:34 +0100 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2014-05-19 22:39:28 -0700 |
| commit | 45ebfa383f3416cd99ada5355df1e3cc5ff9b141 (patch) | |
| tree | 64502eb16f648f2965ed8c88f2fb6857d0887d02 /src/msvmmaj_train.c | |
| parent | work on regularization term with nonlinearity (diff) | |
| download | gensvm-45ebfa383f3416cd99ada5355df1e3cc5ff9b141.tar.gz gensvm-45ebfa383f3416cd99ada5355df1e3cc5ff9b141.zip | |
reached basic functionality of nonlinear training and grid search
Diffstat (limited to 'src/msvmmaj_train.c')
| -rw-r--r-- | src/msvmmaj_train.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/msvmmaj_train.c b/src/msvmmaj_train.c index 5018c3f..0f42ff6 100644 --- a/src/msvmmaj_train.c +++ b/src/msvmmaj_train.c @@ -79,7 +79,8 @@ void msvmmaj_optimize(struct MajModel *model, struct MajData *data) while ((it < MAX_ITER) && (Lbar - L)/L > model->epsilon) { - // ensure V contains newest V and Vbar contains V from previous + // ensure V contains newest V and Vbar contains V from + // previous msvmmaj_get_update(model, data, B, ZAZ, ZAZV, ZAZVT); if (it > 50) msvmmaj_step_doubling(model); @@ -87,7 +88,7 @@ void msvmmaj_optimize(struct MajModel *model, struct MajData *data) Lbar = L; L = msvmmaj_get_loss(model, data, ZV); - if (it%1 == 0) + if (it%100 == 0) note("iter = %li, L = %15.16f, Lbar = %15.16f, " "reldiff = %15.16f\n", it, L, Lbar, (Lbar - L)/L); it++; @@ -161,7 +162,7 @@ double msvmmaj_get_loss(struct MajModel *model, struct MajData *data, for (j=0; j<K-1; j++) { rowvalue += pow(matrix_get(model->V, K-1, i, j), 2.0); } - value += model->J[i] * rowvalue; + value += data->J[i] * rowvalue; } loss += model->lambda * value; @@ -422,6 +423,7 @@ void msvmmaj_get_update(struct MajModel *model, struct MajData *data, double *B, 1.0, ZAZV, K-1); + /* * Add lambda to all diagonal elements except the first one. Recall * that ZAZ is of size m+1 and is symmetric. @@ -429,7 +431,7 @@ void msvmmaj_get_update(struct MajModel *model, struct MajData *data, double *B, i = 0; for (j=0; j<m; j++) { i += (m+1) + 1; - ZAZ[i] += model->lambda * model->J[j+1]; + ZAZ[i] += model->lambda * data->J[j+1]; } // For the LAPACK call we need to switch to Column- |
