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

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

?? svmfusvmlargeopt.cpp

?? This is SvmFu, a package for training and testing support vector machines (SVMs). It s written in C
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
  int i;  int totFound;  int size = getSize();  int yPos = 0, yNeg = 0;  for (i = 0; i < size; i++) {    if (getY(i) == 1) { yPos++; }    else { yNeg++; }  }      int yNegDes = (yNeg*sS)/size;  int yPosDes = sS-yNegDes;    if (verbosity_ > 0) {    cout << "The training set contains " << yPos << " positive and "	 << yNeg << " negative examples." << endl;  }    // initInfo initInfoArray[2] = { { 0, sS/2+(sS%2), 0, 0, 1 },  // { 0, sS/2, 0, sS-1, -1 } };  initInfo initInfoArray[2] = { { 0, yPosDes, 0, 0, 1 },				{ 0, yNegDes, 0, sS-1, -1 } };      for (i = 0, totFound = 0; i < size; i++) {    initInfo* iip;    iip = (getY(i) == 1 ? &initInfoArray[0] : &initInfoArray[1]);          if (totFound < sS || iip->numGood < iip->maxGood) {      if (totFound >= sS) {	// We thought we might need this example in the initial	// working set, but we've now found enough examples from	// the other class, so push it onto the queue.	int elt = workingSet_[iip->startPos];	workingSetPos_[elt] = -1;	eltQueue_.push(QueueElt_(elt,0));	initInfo* iip2 = 	  (getY(i) == 1 ? &initInfoArray[1] : &initInfoArray[0]);	iip2->numFound--;      }      workingSet_[iip->startPos] = i;      workingSetPos_[i] = iip->startPos;      iip->numFound++;      iip->startPos += iip->posChange;      totFound++;    } else {      // We're already got our full complement of examples, push      // this one onto the queue.      eltQueue_.push(QueueElt_(i,0));    }          if (iip->numGood <= iip->maxGood) { iip->numGood++; }  }  // Attempt at consistency check.  if (initInfoArray[0].numGood == 0 || initInfoArray[1].numGood == 0) {    cerr << "Error: No " <<       (initInfoArray[0].numGood == 0 ? "positive" : "negative") <<       "examples in data set.  Aborting." << endl;    exit(1);  }    if (verbosity_ > 1) {    cout << "Initial chunk contains " << initInfoArray[0].numFound	 << " positive examples and " << initInfoArray[1].numFound	 << " negative examples." << endl << endl;  }}/*! Puts as many USV's as possible into the working set; * then pops enough elements off the queue to fill the working set. */CallTemplate(void, createInitialWorkingSetWarm)() {  int totSize = getSize();  int numFound = 0;  // First, put as many USVs as possible into the working set.  for (int i = 0; i < totSize; i++) {    if (unbndSupVecP(i) && numFound < chunkSize_) {      workingSet_[numFound] = i;      workingSetPos_[i] = numFound;      numFound++;    } else {      eltQueue_.push(QueueElt_(i, -KKT_ViolationAmt(i)));    }  }    // Warn if there's not enough space...  if (getNumUnbndSupVecs() > numFound) {    cerr << "WARNING:  Not enough room in chunk to hold all USVs.  Badbadbad."	 << endl;  }  // add as many more points as necessary  // set<QueueElt_>::iterator it = eltQueue_.end();  while (numFound < chunkSize_) {    QueueElt_ qe = eltQueue_.top();    eltQueue_.pop();    workingSet_[numFound] = qe.elt_;    workingSetPos_[qe.elt_] = numFound;    numFound++;  }}CallTemplate(void, createInitialWorkingSetHot)() {  int i;    for (i = 0; i < chunkSize_; i++) {    workingSet_[i] = chunkKernCache_->getColToTrnSet(i);  }  for (i = 0; i < svmSize_; i++) {    workingSetPos_[i] = chunkKernCache_->getTrnSetToCol(i);  }    // Check to make sure it's ok.  for (i = 0; i < chunkSize_; i++) {    if (workingSet_[i] == -1) {      createInitialWorkingSetCold();      return;    }  }  // Otherwise, push all the unused element uinto the queue.  for (i = 0; i < svmSize_; i++) {    if (workingSetPos_[i] == -1) {      eltQueue_.push(QueueElt_(i, KKT_ViolationAmt(i)));    }  }}CallTemplate(void, buildAndSolveChunk)() {  chunkSvm_ =     new SvmSmallOpt<DataPt, KernVal>    (chunkSize_, chunkY_, chunkTrnSetPtr_, kernProdFuncPtr_,     10, tol_, getEpsilon(), chunkKernCache_);  chunkSvm_->setCVec(chunkC_Vec_);  chunkSvm_->setB(getB());  chunkSvm_->setAllAlphas(chunkAlphas_);      // At THIS point in the code, outputs_[ex] is correct  // for all points IN THE WORKING SET, so we can use this to determine  // the offsets.  DoubleVec offsets = new double[chunkSize_];  for (int i = 0; i < chunkSize_; i++) {    offsets[i] = outputs_[workingSet_[i]] -       chunkSvm_->outputAtTrainingExample(i);  }  chunkSvm_->setOffsetVec(offsets);  chunkSvm_->optimize();    verbosity_ > 0 ? chunkSvm_->fixB() : chunkSvm_->fixB(false);  majorIterations_++;  if (verbosity_ > 0) {    cout << "CHUNK OPTIMIZATION " << majorIterations_ << " COMPLETE (#USVs=" 	 << chunkSvm_->getNumUnbndSupVecs() << ", #SVs=" 	 << chunkSvm_->getNumSupVecs() << ")" << endl << endl;  }  delete[] offsets;}  CallTemplate(void, destroyChunk)() {  delete chunkSvm_;}/*! \fn void SvmLargeOpt<DataPt, KernVal>::updateAlphasAndB () * * (1) Clears removal queue<br> * (2) Copies alphas and B out of our SvmSmallOpt * (3) Sorts the working set into removalQueue_ based *     on KKT_ViolationAmt  */CallTemplate(void, updateAlphasAndB)() {  int i;  // Clear removalQueue_ of old values (if any)  while (removalQueue_.size()) { removalQueue_.pop(); }  // removalQueue_.clear();  AlphaDiffElt_ *alphaDiffs = new AlphaDiffElt_[chunkSize_];  DoubleVec chunkAlphas = chunkSvm_->getAllAlphas();    double phi = 0;  double bDiff = chunkSvm_->getB() - getB();  // Delete excess rows from kernelCache;  double eps = getEpsilon();  alphaDiffHistory_.push_back(alphaDiffs);    int cnt = 0;  for (i = 0; i < chunkSize_; i++) {    chunkAlphas_[i] = chunkAlphas[i]; // temporary to permanent    int ex = workingSet_[i];    double diff = chunkAlphas[i] - getAlpha(ex);    if (fabs(diff) > eps) {      alphaDiffs[cnt].elt_ = ex;      alphaDiffs[cnt].diff_ = diff;                  phi += getY(ex)*diff*(chunkSvm_->outputAtTrainingExample(i)-outputs_[ex]-bDiff);      cnt++;    }    setAlpha(ex, chunkAlphas[i]);    outputs_[ex] = chunkSvm_->outputAtTrainingExample(i);    lastCheckIter_[ex] = majorIterations_;    // Now place an element on the removal queue.    double KKT_Dist = KKT_ViolationAmt(ex);    // Add 10 to remove "zero" elements first.  Kludge.    removalQueue_.push(QueueElt_(ex, -KKT_Dist + (getAlpha(ex) < eps ? 10 : 0)));  }  alphaDiffLengths_.push_back(cnt);      delete[] chunkAlphas;      // If we're actually done, the b from the chunk will be the  // same as the b implied by an USV's not in the chunk (hopefully,  // there won't be any of those anyway...)  bHistory_.push_back(getB()); // Put the OLD value of b in history  setB(chunkSvm_->getB());  // cout << "PHI = " << phi << endl;  phis_.push_back(phi);  if (usingLinear_) {    int i;    for (i = 0; i < linDims_; i++) {      w_[i] = 0;    }        int size = getSize();    double eps = getEpsilon();    for (i = 0; i < size; i++) {      if (getAlpha(i) > eps) {	addToWPtr_(w_, getTrainingExample(i), getY(i)*getAlpha(i));      }    }  }}CallTemplate(double, outputAtTrainingExample)(int ex) const {  updateNumber_++;  int i, e;  int size = getSize();      if (updateNumber_ >= SVM_RESET_UPDATES_HOW_OFTEN) {    updateNumber_ = 1;    for (i = 0; i < size; i++) {      updateHelper_[i] = 0;    }  }  // if we have to recalculate the output for this point  if (lastCheckIter_[ex] != majorIterations_) {     if (usingLinear_) {      outputs_[ex] = multWPtr_(w_, getTrainingExample(ex)) + getB();     } else {      int lC = lastCheckIter_[ex];            // for each iteration since we last updated      while (lC < majorIterations_) {	AlphaDiffElt_ *aD = alphaDiffHistory_[lC];		// for each diff in this iteration, update the output for this point	for (i = 0; i < alphaDiffLengths_[lC]; i++) {	  e = aD[i].elt_;	  	  if (updateHelper_[e] != updateNumber_) {	    tempKernProds_[e] = chunkKernCache_->trnSetKernProd(ex, e);	    updateHelper_[e] = updateNumber_;	  }	  	  outputs_[ex] += getY(e)*aD[i].diff_*tempKernProds_[e];	}		lC++;      }          outputs_[ex] -= bHistory_[lastCheckIter_[ex]];      outputs_[ex] += getB();    }        lastCheckIter_[ex] = majorIterations_;  }      return outputs_[ex];}/*! \fn SvmLargeOpt<DataPt, KernVal>::KKT_ViolationAmt (int) * * Returns KKT violation for the specified point in the training set */CallTemplate(double, KKT_ViolationAmt)(int ex) const {  // Added this bit so that if a point has a C of 0, it will always  // return a violation of zero and won't be added to a working set.  // This makes sense because even if C=0 for a point, that point ALWAYS  // satisfies the optimality conditions, since its alpha can't move.  // We don't even need to do the computation here.  double C = getC(ex);  double eps = getEpsilon();  if (C < eps) { return 0; }  double yerr = getY(ex)*outputAtTrainingExample(ex);  double alpha = getAlpha(ex);  if (alpha < eps) {     return 1 - yerr;   } else if (alpha > C - eps) {    return yerr - 1;  } else {    return fabs(yerr-1);  }}/*! \fn SvmLargeOpt<DataPt, KernVal>::pivotWorkingSet (int, int) * * (1) Update chunk data structures to reflect the swap<br> * (2) Adds cells for the point to the kernel cache */CallTemplate(void, pivotWorkingSet)(int pointToAdd, 				    int pointToRemove) {  int wsPos = workingSetPos_[pointToRemove];  ///////////////////  // error checking  ///////////////////  if (wsPos < 0 || wsPos > chunkSize_) {    cerr << "ERROR!  wsPos out of range: " << wsPos << endl;    exit(1);  }  if (workingSetPos_[pointToAdd] != -1) {    cerr << pointToAdd << " is ALREADY in wset!" << endl;    exit(1);  }  if (pointToAdd < 0 || pointToAdd > getSize()) {    cerr << "POINT TO ADD RANGE: " << pointToAdd << endl;    exit(1);  }  if (pointToRemove < 0 || pointToRemove > getSize()) {    cerr << "POINT TO Remove RANGE: " << pointToRemove << endl;    exit(1);  }    ///////////////////////////////////////  // update working set data structures  ///////////////////////////////////////  workingSetPos_[pointToAdd] = wsPos;  workingSetPos_[pointToRemove] = -1;  workingSet_[wsPos] = pointToAdd;      chunkY_[wsPos] = getY(pointToAdd);  chunkC_Vec_[wsPos] = getC(pointToAdd);  chunkTrnSetPtr_[wsPos] = getTrainingExample(pointToAdd);  chunkAlphas_[wsPos] = getAlpha(pointToAdd);}CallTemplate(double, dualObjFunc)() const {  double b = getB();  double result = 0.0;  int size = getSize();      for (int i = 0; i < size; i++) {    result += getAlpha(i)*(1-.5*getY(i)*(outputs_[i]-b));  }      return result;}CallTemplate(void, getCurrentOutputVals)(DoubleVec outputVals) {  int size = getSize();    for (int i = 0; i < size; i++) {    outputVals[i] = outputAtTrainingExample(i);  }}CallTemplate(int, computeLeaveOneOutErrors)(DoubleVec LOO_Vals) {  int size = getSize();  int i;    double eps = getEpsilon();  BoolVec LOO_CompNeededP_ = new bool[size];  if (!optimized_) {    cerr << "Error:  Cannot compute Leave-One-Out Errors on an unoptimized SVM." << endl;    return 0;  }  if (verbosity_ > 0) {    cout << "Computing Leave-One-Out Errors." << endl;  }    // Update all the outputs, just in case.  This can be necessary because  // of the phis.  A little more care could possibly save some time here,  // but this is simpler and correct.  computeTrainingSetPerf(false);    int compsNeeded = 0;  for (i = 0; i < size; i++) {    if (getAlpha(i) < eps) {      LOO_CompNeededP_[i] = false;      LOO_Vals[i] = outputAtTrainingExample(i);    } else {      compsNeeded++;      LOO_CompNeededP_[i] = true;      LOO_Vals[i] = 0;    }  }  int numErrors = computeLeaveOneOutErrorsInternal(LOO_CompNeededP_, LOO_Vals);  delete[] LOO_CompNeededP_;  if (verbosity_ > 0) {    cout << "Done." << endl;  }    return numErrors;}CallTemplate(int, computeLeaveOneOutErrorsInternal)(BoolVec LOO_CompNeededP,						    DoubleVec LOO_Vals) {  int size = getSize();  int i, j, k;  int numErrors = 0;  double eps = getEpsilon();  int workSetPos;    int oldVerbosity = verbosity_;  verbosity_ = 0;  for (i = 0; i < size; i++) {    if (LOO_CompNeededP[i]) {      double oldC = getC(i);      double alphaRemains = getAlpha(i);      int yI = getY(i);      double aI = getAlpha(i);      // Delete the alpha from all the cached outputs      for (j = 0; j < size; j++) {	outputs_[j] -= yI*aI*chunkKernCache_->trnSetKernProd(i,j);      }      j = -1;      while (alphaRemains > eps) {	j++;	if (i == j) { continue; }	if (j >= size) {	  cerr << "Error: Couldn't adjust solution in LOO computation.  Aborting."	       << endl;	  exit(-1);	}	double cJ = getC(j);	double aJ = getAlpha(j);	int yJ = getY(j);	double diffAvail = 0;	if (yJ == yI && aJ < cJ-eps) { diffAvail = cJ - aJ; }	if (yJ != yI && aJ > eps) { diffAvail = aJ; }		diffAvail = diffAvail > alphaRemains ? alphaRemains : diffAvail;	if (diffAvail > eps) {	  for (k = 0; k < size; k++) {	    outputs_[k] += yJ*(yI*yJ*diffAvail)*chunkKernCache_->trnSetKernProd(j,k);	  }	  setAlpha(j, aJ + yI*yJ*diffAvail);	  workSetPos = chunkKernCache_->getTrnSetToCol(j);	  if (workSetPos != -1) {	    chunkAlphas_[workSetPos] += yI*yJ*diffAvail;	  }	  alphaRemains -= diffAvail;	}      }      setAlpha(i,0);      setC(i, 0);      workSetPos = chunkKernCache_->getTrnSetToCol(i);      if (workSetPos != -1) {	chunkC_Vec_[workSetPos] = 0;	chunkAlphas_[workSetPos] = 0;      }      optimized_ = false;      reoptimize();            double output = outputAtTrainingExample(i);      if (yI*output <= 0) { numErrors++; }      LOO_Vals[i] = output;            setC(i, oldC);      if (workSetPos != -1) {	chunkC_Vec_[workSetPos] = oldC;      }    }  }  // Get SVM back to "original" solved state.  optimized_ = false;  reoptimize();  verbosity_ = oldVerbosity;  return numErrors;}#include "SvmFuSvmDataPoint.h"#define IterateTypes(datatype, kerntype) \    template class SvmLargeOpt<DataPoint<datatype>, kerntype>;#include "SvmFuSvmTypes.h"//template class vector<QueueElt_>;//    extern template class SvmBase<DataPoint<datatype>, kerntype>; //    extern template class SvmSmallOpt<DataPoint<datatype>, kerntype>; 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区在线影院| 国产不卡视频一区| 丁香婷婷综合网| 欧洲精品在线观看| 国产欧美一区二区三区鸳鸯浴| 亚洲综合自拍偷拍| 欧亚洲嫩模精品一区三区| 日韩欧美一级二级三级久久久| 国产精品国产三级国产普通话蜜臀| 蜜臀av国产精品久久久久| 色综合av在线| 中文字幕中文字幕一区二区 | 久久精品一区二区三区不卡牛牛| 亚洲综合视频网| av在线播放成人| 国产日产精品1区| 国产在线精品视频| 91精品国产全国免费观看 | 日韩欧美国产一区二区在线播放 | 成人免费av网站| www亚洲一区| 另类小说欧美激情| 欧美一区二区三区人| 亚洲成av人片一区二区三区| 99天天综合性| 国产精品国产a| 波多野结衣精品在线| 国产欧美一区在线| 成人晚上爱看视频| 国产精品久久久久毛片软件| 高清不卡一二三区| 国产精品剧情在线亚洲| 成人国产精品免费观看动漫| 欧美高清一级片在线观看| 国产**成人网毛片九色| 中文字幕乱码日本亚洲一区二区 | 麻豆国产精品777777在线| 777xxx欧美| 久久99精品久久久| 久久久久久免费网| 成人午夜精品一区二区三区| 中文字幕色av一区二区三区| 99视频精品在线| 一区二区三区国产豹纹内裤在线| 欧美日韩在线三级| 免费精品视频最新在线| 久久亚洲综合色一区二区三区| 国产在线麻豆精品观看| 亚洲免费在线看| 色欧美乱欧美15图片| 亚洲综合区在线| 日韩精品一区二区三区视频播放| 国产九色精品成人porny| 亚洲国产成人自拍| 欧美在线不卡视频| 麻豆国产精品官网| 国产精品第四页| 欧美日韩国产经典色站一区二区三区 | 欧美日韩大陆一区二区| 蜜桃久久久久久| 国产欧美1区2区3区| 欧美性xxxxxx少妇| 韩国欧美国产一区| 自拍偷拍亚洲综合| 日韩视频在线一区二区| av成人老司机| 蜜臀av一区二区在线观看| 欧美国产1区2区| 7777精品久久久大香线蕉| 国产91丝袜在线18| 亚洲风情在线资源站| 国产亚洲一区字幕| 欧美日韩在线电影| 国产高清成人在线| 天天影视色香欲综合网老头| 国产日韩欧美精品综合| 91精品欧美福利在线观看| 波多野结衣的一区二区三区| 天堂一区二区在线| 最新日韩av在线| www欧美成人18+| 欧美精品乱码久久久久久| 成人免费看黄yyy456| 老司机午夜精品| 亚洲一区二区三区四区在线免费观看 | 99re66热这里只有精品3直播| 日本美女视频一区二区| 亚洲精品综合在线| 国产三级精品视频| 精品国产一区二区三区久久久蜜月| 国产一区二区美女| 天堂午夜影视日韩欧美一区二区| 欧美日韩国产高清一区二区 | 亚洲一区二区免费视频| 久久综合av免费| 51精品久久久久久久蜜臀| 97久久精品人人做人人爽| 国内精品国产成人| 美女国产一区二区三区| 亚洲午夜激情网站| 亚洲欧美另类久久久精品 | 91精品啪在线观看国产60岁| 91久久精品国产91性色tv| 成人妖精视频yjsp地址| 国产综合久久久久影院| 麻豆91在线播放免费| 午夜伦理一区二区| 亚洲电影第三页| 一区二区三区国产| 亚洲女性喷水在线观看一区| 亚洲色图制服丝袜| 综合色天天鬼久久鬼色| 国产精品久久久久久久裸模 | 精品福利一区二区三区| 日韩精品最新网址| 欧美mv和日韩mv的网站| 日韩一级黄色大片| 精品欧美一区二区久久| 精品国产乱码久久久久久久| 欧美一区二区三区精品| 欧美大肚乱孕交hd孕妇| 日韩欧美激情一区| 26uuu精品一区二区三区四区在线| 精品国产一区久久| 久久久久国产精品厨房| 国产欧美日韩视频一区二区| 中文字幕不卡在线观看| 亚洲天堂精品在线观看| 亚洲视频香蕉人妖| 亚洲狠狠爱一区二区三区| 日韩精品电影在线观看| 狠狠狠色丁香婷婷综合激情| 成人亚洲一区二区一| 国产91精品一区二区麻豆亚洲| 成人永久免费视频| 91久久香蕉国产日韩欧美9色| 欧美亚洲高清一区| 欧美第一区第二区| 国产精品午夜在线观看| 一区二区三区视频在线看| 午夜电影久久久| 国产精品正在播放| 色综合一区二区三区| 精品国精品国产尤物美女| 久久久九九九九| 一区二区三区四区在线| 日韩电影在线观看网站| 国产精品伊人色| 一本大道久久a久久精品综合| 欧美剧情片在线观看| 久久精品视频免费| 亚洲精品成人a在线观看| 免费观看在线色综合| 粉嫩aⅴ一区二区三区四区五区| 日本韩国欧美在线| www激情久久| 亚洲最大成人综合| 国产精品456| 欧美高清性hdvideosex| 国产精品色眯眯| 男女男精品网站| 91免费在线视频观看| 精品sm在线观看| 亚洲成年人影院| 99视频有精品| 欧美精品一区男女天堂| 亚洲成a天堂v人片| 成人av资源站| 久久噜噜亚洲综合| 视频一区在线视频| 一本一道久久a久久精品综合蜜臀| 欧美一区二区二区| 亚洲精品日韩综合观看成人91| 狠狠色狠狠色合久久伊人| 欧美理论片在线| 亚洲美女视频一区| 福利视频网站一区二区三区| 日韩亚洲欧美在线| 五月激情丁香一区二区三区| 99精品一区二区| 日本一区二区电影| 国产麻豆精品久久一二三| 日韩无一区二区| 午夜久久久影院| 欧美亚洲综合色| 亚洲日本在线天堂| a级高清视频欧美日韩| 久久久精品免费观看| 精品在线免费视频| 日韩限制级电影在线观看| 婷婷六月综合亚洲| 欧美日韩黄色影视| 亚洲chinese男男1069| 欧美男同性恋视频网站| 亚洲国产成人精品视频| 欧美亚洲动漫精品| 亚洲第一福利视频在线| 欧美视频在线一区| 亚洲午夜久久久久中文字幕久| 欧美性猛交一区二区三区精品|