diff options
| author | Joe Zhao <ztuowen@gmail.com> | 2015-05-13 19:58:53 +0800 | 
|---|---|---|
| committer | Joe Zhao <ztuowen@gmail.com> | 2015-05-13 19:58:53 +0800 | 
| commit | 47296445b3c5cbea101a5961ef784eb05c84f854 (patch) | |
| tree | 2495539d095be74134c3ac1ed66a16ee7b79778f | |
| parent | 52ca742e14e36cd37010bae9a7678dd5b1a7eaf5 (diff) | |
| download | ranksvm-47296445b3c5cbea101a5961ef784eb05c84f854.tar.gz ranksvm-47296445b3c5cbea101a5961ef784eb05c84f854.tar.bz2 ranksvm-47296445b3c5cbea101a5961ef784eb05c84f854.zip  | |
mem tested
| -rw-r--r-- | model/rankaccu.cpp | 2 | ||||
| -rw-r--r-- | model/ranksvmtn.cpp | 16 | ||||
| -rw-r--r-- | tools/dataProvider.h | 14 | 
3 files changed, 18 insertions, 14 deletions
diff --git a/model/rankaccu.cpp b/model/rankaccu.cpp index ba8aee6..726f2c8 100644 --- a/model/rankaccu.cpp +++ b/model/rankaccu.cpp @@ -136,7 +136,7 @@ void rank_CMC(DataList &D,const std::vector<double> pred,CMC & cmc) {              for (int k=j;k<=i;++k)                  if (orig[pred_rank[k]]>0)                  { -                    cout<<dat[pred_rank[k]]->qid<<" "<<pred[k]<<" "<< k-j<<endl; +                    LOG(INFO)<<"qid:"<<dat[pred_rank[k]]->qid<<"; pred:"<<pred[k]<<"; rank:"<< k-j;                      cmc.addEntry(k-j);                      break; // account only for the first match;                  } diff --git a/model/ranksvmtn.cpp b/model/ranksvmtn.cpp index d3ef3af..3136426 100644 --- a/model/ranksvmtn.cpp +++ b/model/ranksvmtn.cpp @@ -8,11 +8,12 @@ using namespace Eigen;  const double C=1e-4; // Compensating & scaling  // Main terminating criteria -const int maxiter = 20; // max iteration count +const int maxiter = 60; // 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 = 10; +const int ls_maxiter = 10;  // line search  const double line_prec=1e-10; // precision  const double line_turb=1e-15; // purturbation @@ -61,11 +62,13 @@ int cg_solve(RidList &D,const vector<int> &rank,const VectorXd &corr,const Vecto      {          // Non preconditioned version          r_1 = res.dot(res); +        if (iter) +        LOG(INFO) << "CG iter "<<iter<<", r:"<<r_1;          if (r_1<cg_prec) // Terminate condition              break; -        if (iter > cg_maxiter) +        if (iter >= cg_maxiter)          { -            LOG(INFO) << "CG forced termination by maxiter, r:"<<r_1; +            LOG(INFO) << "CG forced termination by maxiter";              break;          }          if (iter){ @@ -178,9 +181,10 @@ int line_search(const VectorXd &w,RidList &D,const VectorXd &corr,const VectorXd          if (g*g/h<line_prec)              break;          ++iter; -        if (iter > cg_maxiter) +        LOG(INFO) << "line search iter "<<iter<<", prec:"<<g*g/h; +        if (iter >= ls_maxiter)          { -            LOG(INFO) << "line search forced termination by maxiter, prec:"<<g*g/h; +            LOG(INFO) << "line search forced termination by maxiter";              break;          }      } diff --git a/tools/dataProvider.h b/tools/dataProvider.h index a3f3d34..b8c14b2 100644 --- a/tools/dataProvider.h +++ b/tools/dataProvider.h @@ -66,7 +66,7 @@ public:          other.clear();      }      void setfSize(int fsize){n=fsize;} -    int getfSize(){return n;} +    inline int getfSize(){return n;}      void addEntry(DataEntry* d){          int ext=false;          for (int i=0;i<uniq.size();++i) @@ -80,19 +80,19 @@ public:          else              uniq.push_back(d);      } -    int getqSize() +    inline int getqSize()      {          return (int)(uniq.size()+other.size()-1);      } -    int getuSize() +    inline int getuSize()      {          return (int)uniq.size();      } -    int getSize() +    inline int getSize()      {          return getuSize()*getqSize();      } -    Eigen::VectorXd getVec(int x){ +    inline Eigen::VectorXd getVec(int x){          int a,b,n=getqSize();          a=x/n;          b=x%n; @@ -106,8 +106,8 @@ public:              vec=vec-other[b-uniq.size()+1]->feature;          return vec.cwiseAbs();      }; -    double getL(int x){ -        int a,b,n=(int)(uniq.size()+other.size()-1); +    inline double getL(int x){ +        int a,b,n=getqSize();          a=x/n;          b=x%n;          if (b<uniq.size()-1)  | 
