亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? svmfusvmlargeopt.cpp

?? This is SvmFu, a package for training and testing support vector machines (SVMs). It s written in C
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//     This is a part of the SvmFu library, a library for training //     Support Vector Machines.//      //     Copyright (C) 2000  rif and MIT////     Contact: rif@mit.edu//     This program is free software; you can redistribute it and/or//     modify it under the terms of the GNU General Public License as//     published by the Free Software Foundation; either version 2 of//     the License, or (at your option) any later version.//     This program is distributed in the hope that it will be useful,//     but WITHOUT ANY WARRANTY; without even the implied warranty of//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//     GNU General Public License for more details.//     You should have received a copy of the GNU General Public//     License along with this program; if not, write to the Free//     Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,//     MA 02111-1307 USA#include "SvmFuSvmLargeOpt.h"#ifdef CallTemplate#undef CallTemplate#endif#define CallTemplate(rettype, funcname) \template<class DataPt, class KernVal> \rettype SvmLargeOpt<DataPt, KernVal>::funcname#ifdef InlineTemplate#undef InlineTemplate#endif#define InlineTemplate(rettype, funcname) \template<class DataPt, class KernVal> \rettype SvmLargeOpt<DataPt, KernVal>::funcname//! The standard, cold-start constructor, no extraCacheRows argtemplate <class DataPt, class KernVal>SvmLargeOpt<DataPt, KernVal>::SvmLargeOpt(int svmSize, const IntVec y, DataPt *trnSetPtr, const KernVal (*kernProdFuncPtr)(const DataPt &pt1,				  const DataPt &pt2), int chunkSize, double C, double tol, double eps, int verbosity)  : SvmBase<DataPt, KernVal>(svmSize, y, trnSetPtr,			     kernProdFuncPtr, C, eps),  chunkSize_(chunkSize), tol_(tol), majorIterations_(0), updateNumber_(1),   optimized_(false), verbosity_(verbosity), startType_(coldStart),  extraCacheRows_(0){  initInternal();}//! The standard, cold-start constructor, with an extraCacheRows argtemplate <class DataPt, class KernVal>SvmLargeOpt<DataPt, KernVal>::SvmLargeOpt(int svmSize, const IntVec y, DataPt *trnSetPtr, int extraCacheRows, const KernVal (*kernProdFuncPtr)(const DataPt &pt1,				  const DataPt &pt2), int chunkSize, double C, double tol, double eps, int verbosity)  : SvmBase<DataPt, KernVal>(svmSize, y, trnSetPtr,			     kernProdFuncPtr, C, eps),  chunkSize_(chunkSize), tol_(tol), majorIterations_(0), updateNumber_(1),   optimized_(false), verbosity_(verbosity), startType_(coldStart),  extraCacheRows_(extraCacheRows){  initInternal();}//! The warm-start constructor: you have a guess for alpha and b,// and outputs???  I don't understand this.   If you need outputs,// I don't know what the use is.  This should be cut.template <class DataPt, class KernVal>SvmLargeOpt<DataPt, KernVal>::SvmLargeOpt(int svmSize, const IntVec y, DataPt *trnSetPtr, const KernVal (*kernProdFuncPtr)(const DataPt &pt1,				  const DataPt &pt2), DoubleVec cVec, DoubleVec alphaVec, DoubleVec outputVec, double b, int chunkSize, double tol, double eps, int verbosity)  : SvmBase<DataPt, KernVal>(svmSize, y, trnSetPtr,			     kernProdFuncPtr, 1, eps),    chunkSize_(chunkSize), tol_(tol), majorIterations_(0), updateNumber_(1),     optimized_(false), verbosity_(verbosity), outputs_(outputVec),     startType_(warmStart){  initInternal();  setCVec(cVec);  setAllAlphas(alphaVec);  setB(b);}//! The hot-start constructor, you're passing in a *chunkKernCachetemplate <class DataPt, class KernVal>SvmLargeOpt<DataPt, KernVal>::SvmLargeOpt(int svmSize, const IntVec y, DataPt *trnSetPtr, const KernVal (*kernProdFuncPtr)(const DataPt &pt1,				  const DataPt &pt2), DoubleVec cVec, DoubleVec alphaVec, DoubleVec outputVec, double b, int chunkSize,  SvmKernCache<DataPt, KernVal> *chunkKernCache, double tol, double eps, int verbosity)  : SvmBase<DataPt, KernVal>(svmSize, y, trnSetPtr,			     kernProdFuncPtr, 1, eps),    chunkSize_(chunkSize), tol_(tol), majorIterations_(0), updateNumber_(1),     optimized_(false), verbosity_(verbosity), chunkKernCache_(chunkKernCache),    outputs_(outputVec), startType_(hotStart){  initInternal();  setCVec(cVec);  setAllAlphas(alphaVec);  setB(b);}CallTemplate(void, initInternal)() {  int i;  int size = getSize();        if (size < SVM_LARGEOPT_MIN_TOTAL_SIZE) {    cerr << "ERROR: Total size for SvmLargeOpt must be at least " <<      SVM_LARGEOPT_MIN_TOTAL_SIZE << ".  Aborting." << endl;    exit(1);  }        // Check sizes  if (chunkSize_ > size) {    if (verbosity_ >= 2) {      cerr << "Warning: chunkSize_(" << chunkSize_ << 	") > svmSize_(" << size << ").  Adjusting " <<	"chunk size downward." << endl;    }    chunkSize_ = size;  }        workingSetPos_ = new int[size];  lastCheckIter_ = new int[size];  updateHelper_ = new int[size];  tempKernProds_ = new KernVal[size];  if (startType_ == coldStart) { outputs_ = new double[size]; }  for (i = 0; i < size; i++) {     workingSetPos_[i] = -1;    if (startType_ == coldStart) { outputs_[i] = 0; }    lastCheckIter_[i] = 0;    updateHelper_[i] = 0;  }        workingSet_ = new int[chunkSize_];  chunkY_ = new int[chunkSize_];  chunkC_Vec_ = new double[chunkSize_];  chunkAlphas_ = new double[chunkSize_];  chunkTrnSetPtr_ = new DataPt[chunkSize_];  usingLinear_ = false;}CallTemplate(void, useLinearKernel)(int dims, const void(*afunc)(double *&w, const DataPt &p, double amt), const double(*mfunc)(double *w, const DataPt &p)) {  if (usingLinear_ == false) {    int i;    linDims_ = dims;    w_ = new double[dims];    for (i = 0; i < dims; i++) {      w_[i] = 0;    }        int size = getSize();    double eps = getEpsilon();        addToWPtr_ = afunc;    multWPtr_ = mfunc;    for (i = 0; i < size; i++) {      if (getAlpha(i) > eps) {	addToWPtr_(w_, getTrainingExample(i), getY(i)*getAlpha(i));      }    }        usingLinear_ = true;  }}template<class DataPt, class KernVal> SvmLargeOpt<DataPt, KernVal>::~SvmLargeOpt() {  int i;  for (i = 0; i < (int)alphaDiffHistory_.size(); i++) {    delete[] alphaDiffHistory_[i];  }  delete[] workingSet_;  delete[] workingSetPos_;  delete[] chunkY_;  delete[] chunkC_Vec_;  delete[] chunkAlphas_;  delete[] chunkTrnSetPtr_;  if (startType_ == coldStart) { delete[] outputs_; }  delete[] updateHelper_;  delete[] tempKernProds_;    if (chunkKernCacheAllocatedP_) {    delete chunkKernCache_;  }  delete[] selfProds_;  if (usingLinear_) {    delete[] w_;  }}/*! \fn void SvmLargeOpt<DataPt, KernVal>::optimize () * * Optimizes the svm. */CallTemplate(void, optimize)() {  setupAndSolveInitialChunk();  if (verbosity_ >= 2) cout << "Solved initial chunk." << endl;  while (setupAndSolveNewChunk()) {    if (verbosity_ >= 2) cout << "Solved chunk." << endl;	  }      optimized_ = true;}CallTemplate(void, reoptimize)() {  if (verbosity_ >= 2) cout << "Forcing current chunk." << endl;  forceCurrentChunk();  while (setupAndSolveNewChunk()) {    if (verbosity_ >= 2) cout << "Solved chunk." << endl;	  }  optimized_ = true;}CallTemplate(void, setupAndSolveInitialChunk)() {  createInitialWorkingSet();  setupInitialChunkData();  if (verbosity_ >= 2) cout << "Setup initial chunk data. " << endl;  buildAndSolveChunk();  if (verbosity_ >= 2) cout << "Built and solved initial chunk. " << endl;  updateAlphasAndB();  if (verbosity_ >= 2) cout << "Updated alphas and B. " << endl;  destroyChunk();}/*! \fn void SvmLargeOpt<DataPt, KernVal>::setupInitialChunkData () * * Sets up the initial chunk using the indices from workingSet_ * and creates the kernel cache. */CallTemplate(void, setupInitialChunkData)() {  int i;    for (i = 0; i < chunkSize_; i++) {    int ex = workingSet_[i];    chunkY_[i] = getY(ex);    chunkC_Vec_[i] = getC(ex);    chunkTrnSetPtr_[i] = getTrainingExample(ex);    chunkAlphas_[i] = getAlpha(workingSet_[i]);  }  if (startType_ != hotStart) {    chunkKernCache_ = new SvmKernCache<DataPt, KernVal>      (chunkSize_, extraCacheRows_, svmSize_, trnSetPtr_, kernProdFuncPtr_);    chunkKernCacheAllocatedP_ = true;  } else {    chunkKernCacheAllocatedP_ = false;  }  chunkKernCache_->workingSetChanged(workingSet_, eltQueue_);  // This now goes here because we need the initialization of the  // data structure done by workingSetChanged to happen BEFORE we  // read the cachedKernProds.  Bad Hack.  int size = getSize();  selfProds_ = new KernVal[size];  if (startType_ == hotStart && chunkKernCache_->readFromFile_) {    for (i = 0; i < size; i++) {      selfProds_[i] = chunkKernCache_->cachedKernProd(i,i);    }  } else {    for (i = 0; i < size; i++) {      selfProds_[i] = kernProdFuncPtr_(getTrainingExample(i),				       getTrainingExample(i));    }  }}CallTemplate(bool, setupAndSolveNewChunk)() {  // if we can improve the working set...  if (updateWorkingSetAndChunkData()) {    buildAndSolveChunk();    updateAlphasAndB();    destroyChunk();        return true;  } else {    return false;  }}CallTemplate(void, forceCurrentChunk)() {  buildAndSolveChunk();  updateAlphasAndB();  destroyChunk();}/*! \fn bool SvmLargeOpt<DataPt, KernVal>::updateWorkingSetAndChunkData () * * Prepares a new working set for optimization by an SvmSmallOpt. * * Returns false if we're done. * * \todo make sure iteration through the sets is in the proper direction */CallTemplate(bool, updateWorkingSetAndChunkData)() {    int numUSVs = getNumUnbndSupVecs();  int maxToAdd = chunkSize_-numUSVs-SVM_LARGEOPT_NON_USVS_TO_KEEP;  int origQueueSize = eltQueue_.size();  int size, i;  bool didAPivot = false;  ////////////////////  // bounds checking  ////////////////////    if (origQueueSize == 0) {    if (verbosity_ >= 2) {      cerr << "WARNING: All elements are in the working set --- we're done." 	   << endl;    }    return false;  }  if (maxToAdd < SVM_LARGEOPT_MIN_TO_ADD) {    maxToAdd = SVM_LARGEOPT_MIN_TO_ADD;    if (maxToAdd > chunkSize_) { maxToAdd = chunkSize_; }    if (verbosity_ >= 2) {       cerr << "WARNING: chunkSize = " << chunkSize_	   << ", numUSVs = " << numUSVs << "; things could get SLOW..."	   << endl;    }  }  ////////////////////////////////////////////////  // choose points to add to the working set and  // update the working set data structures  ////////////////////////////////////////////////  int numPointsFound = 0;  int numPointsChecked = 0;  int numPointsShrunk = 0;  int checksSinceLastFind = 0;  int firstFound = -1;  int lastFound = -1;  int maxGapSize = 0;  int curGapSize = 0;  list<QueueElt_> removedPoints;  list<QueueElt_> checkedNotAddedPoints;    double *phiDiffs = new double[majorIterations_];  double curPhi = 0;    for (i = majorIterations_ - 1; i >= 0; i--) {    curPhi += phis_[i];    phiDiffs[i] = curPhi;  }  int pointsRemoved, SVsRemoved, SVsAdded;  pointsRemoved = SVsRemoved = SVsAdded = 0;    while ((numPointsChecked < origQueueSize) &&	 ((numPointsFound == 0) ||	  ((numPointsFound < maxToAdd) && 	   (checksSinceLastFind <= firstFound+	    SVM_LARGEOPT_MAX_NONFIND_CHECKS)))) {    QueueElt_ qe = eltQueue_.top();    eltQueue_.pop();    int ex = qe.elt_;        double alpha = getAlpha(ex);    bool checkNeeded = false;    int lc = lastCheckIter_[ex];    double rho = sqrt(selfProds_[ex]*phiDiffs[lc]) + getB() - bHistory_[lc];    double oldOut = outputs_[ex];    int y = getY(ex);        double eps = getEpsilon();    if (alpha < eps) {      if (y*oldOut - rho < 1) { checkNeeded = true; }    } else if (alpha > getC(ex) - eps) {      if (y*oldOut + rho >= 1) { checkNeeded = true; }    } else { // USV not in the working set, check it.      checkNeeded = true;    }        double KKT_Dist = 0;    if (checkNeeded) {       KKT_Dist = KKT_ViolationAmt(ex);    }          // if the point is a violator    if (KKT_Dist > tol_) {      // remove the least offending point from the removal queue       QueueElt_ pointToRemove = removalQueue_.top();      removalQueue_.pop();      pointsRemoved ++;      if (alpha > 0) { SVsAdded++; }      if (getAlpha(pointToRemove.elt_) > 0) { SVsRemoved++; }            // Store the removed point in a list, so we can put it on the       // to be checked queue AFTER the round.      removedPoints.push_back(pointToRemove);      // update the working set with the new point      pivotWorkingSet(ex, pointToRemove.elt_);      // update statistics      checksSinceLastFind = 0;	      if (numPointsFound == 0) { firstFound = numPointsChecked; }      else {		if (curGapSize > maxGapSize) {	  maxGapSize = curGapSize;	}      }            lastFound = numPointsChecked;      numPointsFound++;      curGapSize = 0;    } else {      checkedNotAddedPoints.push_back(QueueElt_(ex, KKT_Dist));      checksSinceLastFind++;      curGapSize++;    }    numPointsChecked++;  }  delete[] phiDiffs;  if (verbosity_ > 0) {    cout << "Checked " << numPointsChecked << " points, adding " 	 << numPointsFound << " to working set." << endl;    cout << "Adding " << SVsAdded << " SVs, removing " << SVsRemoved << " SVs." << endl;  }  ////////////////////////////  // update the kernel cache  ////////////////////////////  // if we changed the working set  if (numPointsFound) {    // add points removed from the working set to the to-be-added set    for (list<QueueElt_>::iterator removedPoints_it = removedPoints.begin();	 removedPoints_it != removedPoints.end(); removedPoints_it++)    {      eltQueue_.push(QueueElt_(removedPoints_it->elt_,			       KKT_ViolationAmt(removedPoints_it->elt_)));    }    // add points we checked but didn't add back to the queue    for (list<QueueElt_>::iterator checkedNotAddedPoints_it =	   checkedNotAddedPoints.begin();	 checkedNotAddedPoints_it != checkedNotAddedPoints.end();	 checkedNotAddedPoints_it++)    {      eltQueue_.push(*checkedNotAddedPoints_it);    }        chunkKernCache_->workingSetChanged(workingSet_, eltQueue_);    return true;  }   else return false;}CallTemplate(void, createInitialWorkingSet)() {  if (startType_ == coldStart) {    createInitialWorkingSetCold();  } else if (startType_ == warmStart) {    createInitialWorkingSetWarm();  } else { // startType_ == hotStart    createInitialWorkingSetHot();  }}/*! \fn void SvmLargeOpt<DataPt, KernVal>::createInitialWorkingSetCold () * * Populates the working set with a balanced selection of points * if possible. * * This is a little complicated.  We make only a single pass * over the data, filling in the working set with positive examples * from the bottom, and negative from the top.  We allow ourselves * to write more than sS/2 of a given class into the array, but if * we later find enough examples of the other class, we overwrite. */CallTemplate(void, createInitialWorkingSetCold)() {  const int sS = chunkSize_; // for readability      // "clever" method for trying to get as many points from  // both classes as possible into the working set.  This avoids  // the need to prerandomize the order of presentation of the  // points, although that's still a good idea for other reasons.      struct initInfo {    int numGood;    int maxGood;    int numFound;    int startPos;    int posChange;  };    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文在线一区二区| 中文字幕一区二区三中文字幕| 国产sm精品调教视频网站| 亚洲丰满少妇videoshd| 亚洲精品久久久蜜桃| 亚洲欧洲日韩一区二区三区| 精品乱人伦小说| 精品久久久久99| 久久精品一二三| 国产日韩欧美一区二区三区乱码| 精品国产一区二区三区四区四 | 国产精品视频线看| 久久精品男人天堂av| 国产欧美日韩另类一区| 国产精品国产三级国产aⅴ原创| 国产精品久久久一本精品| 国产精品电影院| 亚洲一卡二卡三卡四卡无卡久久 | 亚洲图片自拍偷拍| 午夜激情一区二区| 久久国产夜色精品鲁鲁99| 久久不见久久见中文字幕免费| 国产在线不卡一区| 91影院在线免费观看| 欧美三级电影一区| 精品99一区二区| 亚洲视频一二区| 麻豆精品国产91久久久久久| 久久99国产精品尤物| 成人精品视频.| 欧美主播一区二区三区| 精品av综合导航| 亚洲欧洲综合另类| 老司机午夜精品| 99久久婷婷国产综合精品电影| 欧美在线免费播放| 久久久久久毛片| 亚洲综合视频在线| 国产精品一区二区三区网站| 91黄色免费观看| 国产午夜精品一区二区| 午夜精品久久一牛影视| 成人国产亚洲欧美成人综合网| 欧美日韩精品是欧美日韩精品| 久久免费精品国产久精品久久久久| 国产精品另类一区| 久久国产精品72免费观看| 色香蕉久久蜜桃| 国产亚洲一二三区| 午夜精品久久久| 91小视频免费看| 国产日韩精品一区二区浪潮av| 亚洲欧洲性图库| 寂寞少妇一区二区三区| 在线观看亚洲精品视频| 国产情人综合久久777777| 五月婷婷激情综合| 91麻豆国产自产在线观看| xnxx国产精品| 美女mm1313爽爽久久久蜜臀| 一本大道久久精品懂色aⅴ| 欧美激情自拍偷拍| 麻豆成人91精品二区三区| 欧美日韩国产123区| 一区二区三区小说| 色综合久久天天| 18成人在线观看| 成人美女在线观看| 欧美国产精品劲爆| 国产精品一二一区| 久久老女人爱爱| 国产真实乱偷精品视频免| 3751色影院一区二区三区| 亚洲一区二区三区美女| 欧美影院一区二区| 亚洲永久免费av| 欧美日韩一区二区三区在线| 亚洲欧美国产77777| 色婷婷亚洲综合| 一区二区三区av电影| 欧美性猛片xxxx免费看久爱| 亚洲精品欧美在线| 久久草av在线| 欧美激情一区三区| av亚洲精华国产精华| 亚洲视频精选在线| 在线观看av一区| 午夜私人影院久久久久| 8x福利精品第一导航| 欧美aⅴ一区二区三区视频| 日韩午夜精品视频| 国产乱人伦偷精品视频不卡 | 国产精品久久久久久福利一牛影视 | 一区二区三区高清在线| 欧洲精品一区二区三区在线观看| 亚洲午夜一二三区视频| 欧美日韩一区国产| 欧美aaaaa成人免费观看视频| 精品国产免费一区二区三区四区| 国产一区二区不卡老阿姨| 国产欧美精品在线观看| 一本色道a无线码一区v| 亚洲国产视频a| 欧美成人性战久久| 99热精品一区二区| 午夜精品影院在线观看| 国产欧美一区二区在线| 91高清视频在线| 激情综合色播激情啊| 亚洲色图制服丝袜| 日韩欧美国产午夜精品| 成人h版在线观看| 丝袜诱惑制服诱惑色一区在线观看| 日韩午夜在线观看| 91色视频在线| 精彩视频一区二区| 一区二区三区四区亚洲| 欧美大度的电影原声| 99精品1区2区| 精品一区二区三区免费视频| 亚洲色欲色欲www在线观看| 日韩欧美国产不卡| 欧美亚洲综合色| 国产成人在线电影| 日韩精彩视频在线观看| 亚洲色图另类专区| 久久久久久电影| 555www色欧美视频| 日本韩国欧美国产| 成人午夜免费视频| 久久er精品视频| 天天av天天翘天天综合网| 国产精品成人午夜| 久久精品亚洲乱码伦伦中文| 9191国产精品| 日本精品一区二区三区高清| 久久99精品国产麻豆婷婷洗澡| 亚洲日本在线观看| 亚洲国产精品成人综合| 精品少妇一区二区三区视频免付费 | 欧美成人一区二区三区| 欧美视频精品在线观看| 99精品久久免费看蜜臀剧情介绍| 狠狠色狠狠色综合| 免费高清在线一区| 免费三级欧美电影| 午夜av区久久| 亚洲一区自拍偷拍| 一区二区三区精品在线| 亚洲欧美一区二区三区极速播放 | 精品国产免费一区二区三区香蕉| 欧美精三区欧美精三区| 91久久国产最好的精华液| 99re66热这里只有精品3直播 | 日韩激情一二三区| 日本美女一区二区三区视频| 亚洲不卡一区二区三区| 亚洲一区免费在线观看| 一区二区视频在线| 亚洲国产另类av| 亚洲sss视频在线视频| 性久久久久久久| 人禽交欧美网站| 久久精品国产一区二区三区免费看 | 亚洲小少妇裸体bbw| 一区二区三区成人| 亚洲午夜精品17c| 午夜精品久久一牛影视| 日本少妇一区二区| 美国欧美日韩国产在线播放| 蓝色福利精品导航| 国产剧情av麻豆香蕉精品| 国产日韩成人精品| 国产日韩精品一区二区三区| 国产欧美日韩中文久久| 亚洲视频免费观看| 日韩精品一级二级 | 欧美精品日韩一本| 日韩欧美国产一二三区| 国产精品无人区| 亚洲制服丝袜av| 激情欧美一区二区三区在线观看| 狠狠色丁香久久婷婷综合_中| 成人国产一区二区三区精品| 色婷婷综合视频在线观看| 欧美日韩免费高清一区色橹橹 | 国产69精品久久久久毛片| 波多野结衣91| 日韩欧美中文字幕一区| 日本一区二区三区dvd视频在线| 亚洲精品国产一区二区精华液| 爽好多水快深点欧美视频| 久久福利资源站| 91色.com| 久久久91精品国产一区二区精品 | 色婷婷精品久久二区二区蜜臀av | 在线不卡a资源高清| 久久精品男人的天堂| 亚洲国产美女搞黄色| 国产乱国产乱300精品|