From 93ec2b816300b2eb8c00714cedb936a31888ebad Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Mon, 17 Mar 2014 11:45:57 +0100 Subject: work on regularization term with nonlinearity --- src/msvmmaj_train.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/msvmmaj_train.c') diff --git a/src/msvmmaj_train.c b/src/msvmmaj_train.c index 97ee6a1..311b2d4 100644 --- a/src/msvmmaj_train.c +++ b/src/msvmmaj_train.c @@ -86,7 +86,7 @@ void msvmmaj_optimize(struct MajModel *model, struct MajData *data) Lbar = L; L = msvmmaj_get_loss(model, data, ZV); - if (it%50 == 0) + if (it%1 == 0) note("iter = %li, L = %15.16f, Lbar = %15.16f, " "reldiff = %15.16f\n", it, L, Lbar, (Lbar - L)/L); it++; @@ -153,10 +153,12 @@ double msvmmaj_get_loss(struct MajModel *model, struct MajData *data, loss /= ((double) n); value = 0; - for (i=1; iV, K-1, i, j), 2.0); + rowvalue += pow(matrix_get(model->V, K-1, i, j), 2.0); } + value += model->J[i] * rowvalue; } loss += model->lambda * value; @@ -418,12 +420,14 @@ void msvmmaj_get_update(struct MajModel *model, struct MajData *data, double *B, ZAZV, K-1); /* - * Add lambda to all diagonal elements except the - * first one. + * Add lambda to all diagonal elements except the first one. Recall + * that ZAZ is of size m+1 and is symmetric. */ i = 0; - for (j=0; jlambda; + for (j=0; jlambda * model->J[j+1]; + } // For the LAPACK call we need to switch to Column- // Major order. This is unnecessary for the matrix -- cgit v1.2.3