From 653bee4b89131a997043a074d51c28dedb907f5c Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Mon, 18 May 2015 16:17:01 +0800 Subject: output update --- model/ranksvm.cpp | 2 ++ model/ranksvm.h | 2 ++ model/ranksvmtn.cpp | 29 +++++++++++++++++++---------- 3 files changed, 23 insertions(+), 10 deletions(-) (limited to 'model') diff --git a/model/ranksvm.cpp b/model/ranksvm.cpp index 7ee72ac..dd2d9e4 100644 --- a/model/ranksvm.cpp +++ b/model/ranksvm.cpp @@ -8,6 +8,8 @@ using namespace Eigen; using namespace std; +double C=1e-4; // Compensating & scaling + int RSVM::saveModel(const string fname){ std::ofstream fout(fname.c_str()); diff --git a/model/ranksvm.h b/model/ranksvm.h index aa5e1ca..26a3f6d 100644 --- a/model/ranksvm.h +++ b/model/ranksvm.h @@ -37,4 +37,6 @@ public: int setModel(const SVMModel &model); }; +extern double C; + #endif \ No newline at end of file diff --git a/model/ranksvmtn.cpp b/model/ranksvmtn.cpp index 01d9851..0e41861 100644 --- a/model/ranksvmtn.cpp +++ b/model/ranksvmtn.cpp @@ -6,13 +6,13 @@ using namespace std; using namespace Eigen; -const double C=1e-4; // Compensating & scaling // Main terminating criteria -const int maxiter = 20; // max iteration count +const int maxiter = 40; // max iteration count const double prec=1e-10; // precision // conjugate gradient const double cg_prec=1e-10; // precision -const int cg_maxiter = 30; +const int cg_maxiter = 5; // not worth having a large number +const int ls_maxiter = 10; // line search const double line_prec=1e-10; // precision const double line_turb=1e-15; // purturbation @@ -54,11 +54,13 @@ int cg_solve(const MatrixXd &D,const vector &rank,const VectorXd &corr,cons { // Non preconditioned version r_1 = res.dot(res); + if (iter) + LOG(INFO) << "CG iter "< cg_maxiter) + if (iter >= cg_maxiter) { - LOG(INFO) << "CG forced termination by maxiter, r:"< cg_maxiter) + if (iter >= ls_maxiter) { LOG(INFO) << "line search forced termination by maxiter, prec:"< &A1,const vector &A VectorXd alpha,beta; while (true) { - iter+=1; if (iter> maxiter) { LOG(INFO)<< "Maxiter reached"; @@ -208,8 +210,15 @@ int train_orig(int fsize, MatrixXd &D,const vector &A1,const vector &A line_search(weight,D,corr,A1,A2,step,t); weight=weight+step*t; // When dec is small enough - LOG(INFO)<<"Iter: "< maxiter) + { + LOG(INFO)<< "Maxiter reached"; + break; + } + if (nprec < prec) break; } return 0; -- cgit v1.2.3-70-g09d2