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

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

?? example_set.cpp

?? mySvm的最新源程序
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
#include "example_set.h"example_set_c::example_set_c(){  init(0,0);};example_set_c::example_set_c(SVMINT new_total, SVMINT new_dim){  init(new_total,new_dim);};void example_set_c::init(SVMINT new_total, SVMINT new_dim){  examples_total = 0;  capacity=0;  has_y = 0;  has_alphas = 0;  has_scale = 0;  has_pattern_y = 1;  b = 0;  all_alphas = 0;  all_ys = 0;  // create dummy  the_set = new svm_example[1];  the_set[0].example = 0;  dim=0;  Exp = 0;  Var = 0;  filename = new char[MAXCHAR];  filename[0]='\0';  set_dim(new_dim),  resize(capacity);  // set default file format  my_format.sparse = 0;  my_format.where_x = 2;  my_format.where_y = 1;  my_format.where_alpha = 0;  my_format.delimiter = ' ';}; example_set_c::~example_set_c(){  delete []filename;  clear();  if(the_set) delete []the_set;};void example_set_c::set_format(example_format new_format){  my_format = new_format;};void example_set_c::set_filename(char* new_filename){  strcpy(filename,new_filename);}; void example_set_c::clear(){  if(all_alphas){    delete []all_alphas;    all_alphas=0;  };  if(all_ys){    delete []all_ys;    all_ys=0;  };  if(the_set){    SVMINT i;    SVMINT c;    for(i=0;i<capacity;i++){      if(the_set[i].example != 0){	for(c=0;c<the_set[i].length;c++){	  (((the_set[i]).example)[c]).index=28;	  (((the_set[i]).example)[c]).att = 4;	};	delete [](the_set[i].example); 	the_set[i].example=0;      };    };    delete []the_set;  };  if(Exp) delete []Exp;  if(Var) delete []Var;  Exp = 0;  Var = 0;  the_set = new svm_example[1];  the_set[0].example = 0;  dim = 0;  b = 0;  examples_total = 0;  capacity = 0;  has_y = 0;  has_alphas = 0;  has_scale = 0;};  SVMINT example_set_c::size(){  return examples_total;};SVMINT example_set_c::size_pos(){  SVMINT i;  SVMINT count=0;  for(i=0;i<capacity;i++){    if(the_set[i].y > 0){      count++;    };  };  return count;};SVMINT example_set_c::size_neg(){  SVMINT i;  SVMINT count=0;  for(i=0;i<capacity;i++){    if(the_set[i].y < 0){      count++;    };  };  return count;};void example_set_c::set_dim(SVMINT new_dim){  if(new_dim<dim){    throw general_exception("ERROR: Trying to decrease dimension of examples");  };                                                                              dim = new_dim;  if(Exp) delete []Exp;  if(Var) delete []Var;  Exp = 0;  Var = 0;};SVMINT example_set_c::get_dim(){  return dim;};void example_set_c::resize(SVMINT new_total){  svm_example* new_set = 0;  SVMINT i;  if(new_total > capacity){    // add new space to set    new_set = new svm_example[new_total];    // copy old values    for(i=0;i<capacity;i++){      new_set[i] = the_set[i];    };    for(i=capacity;i<new_total;i++){      new_set[i].example = 0;      new_set[i].length = 0;    };    delete []the_set;    the_set=new_set;    capacity = new_total;    if(all_alphas != 0){      delete []all_alphas;      all_alphas = 0;    };    if(all_ys != 0){      delete []all_ys;      all_ys = 0;    };  }  else if(new_total < capacity){    new_set = new svm_example[new_total];    // copy remaining values    for(i=0;i<new_total;i++){      new_set[i] = the_set[i];    };    // delete obsolete values    for(i=new_total;i<capacity;i++){      if(the_set[i].example != 0){	delete [](the_set[i].example); 	the_set[i].example = 0;	examples_total--;      };    };    delete []the_set;    the_set=new_set;    capacity = new_total;    if(all_alphas != 0){      delete []all_alphas;      all_alphas = 0;    };    if(all_ys != 0){      delete []all_ys;      all_ys = 0;    };  };};void example_set_c::swap(SVMINT i, SVMINT j){  svm_example ex_dummy;  SVMFLOAT dummy;  ex_dummy=the_set[i];  the_set[i] = the_set[j];  the_set[j] = ex_dummy;  if(all_alphas != 0){    dummy=all_alphas[i];    all_alphas[i] = all_alphas[j];    all_alphas[j] = dummy;  };  if(all_ys != 0){    dummy = all_ys[i];    all_ys[i] = all_ys[j];    all_ys[j] = dummy;  };};void example_set_c::put_example(const SVMINT pos, const SVMFLOAT* example){  // examples is SVMFLOAT-array 1..dim  SVMINT non_zero=0;  svm_attrib* new_att;  SVMINT i;  for(i=0;i<dim;i++){    if(0 != example[i]){      non_zero++;    };  };  if(pos>=capacity){    // make set bigger    resize(2*capacity+1);  };  if(0 == the_set[pos].example){    // add new example, reserve space for y and alpha    examples_total++;  }  else{    delete [](the_set[pos].example);    the_set[pos].example = 0;  };  new_att = new svm_attrib[non_zero];  the_set[pos].example = new_att;  // add attributes  SVMINT j=0;  for(i=0;i<non_zero;i++){    while(0 == example[j]) j++;    new_att[i].att = example[j];    new_att[i].index=j;    j++;  };  the_set[pos].y = example[dim];  the_set[pos].alpha = example[dim+1];  the_set[pos].length = non_zero;  if(all_alphas != 0){    all_alphas[pos] = the_set[pos].alpha;  };  if(all_ys != 0){    all_ys[pos]=the_set[pos].y;  };  if((the_set[pos].y != 1) && (the_set[pos].y != -1)){    has_pattern_y = 0;  };};void example_set_c::put_example(const SVMFLOAT* example){  put_example(examples_total,example);};void example_set_c::put_example(const SVMINT pos, const svm_example example){  if(pos>=capacity){    // make set bigger    resize(2*capacity+1);  };  if(the_set[pos].example != 0){    // overwrite old    delete [](the_set[pos].example);    the_set[pos].example = 0;  }  else{    examples_total++;  };  the_set[pos].length = example.length;  svm_attrib* new_att = new svm_attrib[example.length];  SVMINT i;  for(i=0;i<example.length;i++){    new_att[i] = example.example[i];  };  the_set[pos].example = new_att;  the_set[pos].y = example.y;  the_set[pos].alpha = example.alpha;  if(all_alphas != 0){    all_alphas[pos] = the_set[pos].alpha;  };  if(all_ys != 0){    all_ys[pos] = the_set[pos].y;  };  if((the_set[pos].y != 1) && (the_set[pos].y != -1)){    has_pattern_y = 0;  };};void example_set_c::put_example(const svm_example example){  put_example(examples_total,example);};svm_example example_set_c::get_example(const SVMINT pos){  return the_set[pos];};void example_set_c::put_y(const SVMINT pos, const SVMFLOAT y){  the_set[pos].y = y;  if(all_ys != 0){    all_ys[pos] = y;  };  if((y != 1) && (y != -1)){    has_pattern_y = 0;  };};SVMFLOAT example_set_c::get_y(const SVMINT pos){  return (the_set[pos].y);};void example_set_c::put_alpha(const SVMINT pos, const SVMFLOAT alpha){  the_set[pos].alpha = alpha;  if(all_alphas != 0){    all_alphas[pos] = alpha;  };};SVMFLOAT example_set_c::get_alpha(const SVMINT pos){  return (the_set[pos].alpha);};void example_set_c::put_b(const SVMFLOAT new_b){  b=new_b;};SVMFLOAT example_set_c::get_b(){  return b;};SVMFLOAT* example_set_c::get_alphas(){  if(0 == all_alphas){    SVMINT the_size = size();    all_alphas = new SVMFLOAT[the_size];    SVMINT i;    for(i=0; i<the_size; i++){      all_alphas[i] = get_alpha(i);    };  };  return all_alphas;};SVMFLOAT* example_set_c::get_ys(){  if(0 == all_ys){    SVMINT the_size = size();    all_ys = new SVMFLOAT[the_size];    SVMINT i;    for(i=0; i<the_size; i++){      all_ys[i] = get_y(i);    };  };  return all_ys;};void example_set_c::compress(){  // remove zeros out of examples  SVMINT next=0;  SVMINT i=0;  for(i=0;i<capacity;i++){    if(the_set[i].example != 0){      the_set[next] = the_set[i];      if(next != i){	the_set[i].example = 0;	the_set[i].length = 0;      };      next++;    };  };  resize(next);};void example_set_c::scale_alphas(const SVMFLOAT factor){  // set alpha -> factor*alpha  SVMINT i;  for(i=0;i<capacity;i++){    put_alpha(i,factor*get_alpha(i));  };  if(all_alphas){    for(i=0;i<capacity;i++){      all_alphas[i] = get_alpha(i);    };  };};SVMFLOAT example_set_c::get_y_var(){  if(0 != Var ){    if(0 != Var[dim]){      return  Var[dim];    };  };  return 1;};void example_set_c::scale(){  scale(1);};void example_set_c::scale(int scale_y){  if(examples_total == 0) return;  if(Exp == 0) Exp = new SVMFLOAT[dim+1];  if(Var == 0) Var = new SVMFLOAT[dim+1];  SVMINT i;  // calculate Exp and Var   for(i=0;i<=dim;i++){    Exp[i] = 0;    Var[i] = 0;  };  SVMINT pos;  svm_attrib the_att;  for(pos=0;pos<capacity;pos++){    for(i=0;i<the_set[pos].length;i++){      the_att = (the_set[pos].example)[i];      Exp[the_att.index] += the_att.att;      Var[the_att.index] += the_att.att*the_att.att;    };    Exp[dim] += the_set[pos].y;    Var[dim] += the_set[pos].y*the_set[pos].y;  };  for(i=0;i<=dim;i++){    Exp[i] /= examples_total;    Var[i] = (Var[i]-examples_total*Exp[i]*Exp[i])/(examples_total-1);    if(Var[i] > 0){      Var[i] = sqrt(Var[i]);    }    else{      // numerical error      Var[i] = 0;    };  };  if(! scale_y){    Exp[dim] = 0;    Var[dim] = 0;  };  do_scale();};void example_set_c::do_scale(){  // scale  // precondition: Exp and Var are set.  SVMINT i;  SVMINT j=0;  SVMINT k;  //  SVMINT length;  SVMINT nonzero=0;  SVMINT pos;  for(i=0;i<dim;i++){    if(Var[i] != 0) nonzero++;  };  for(pos=0;pos<capacity;pos++){    //    length = the_set[pos].length;    // put zeros into vector, they might be scaled, kick constant atts out    svm_attrib* new_example = new svm_attrib[nonzero];    j = 0; // index in new vector    k = 0; // index in old vector    i=0;    while((i<dim) && (j < nonzero)){      if((k < the_set[pos].length) && (((the_set[pos].example)[k]).index < i)){	k++;      };      if(Var[i] != 0){	new_example[j].index = i;	if(((the_set[pos].example)[k]).index == i){	  new_example[j].att = ((the_set[pos].example)[k]).att;	}	else{	  new_example[j].att = 0;	};	j++;      };      i++;    };        //    length = nonzero;    the_set[pos].length = nonzero;    delete []the_set[pos].example;    the_set[pos].example = new_example;    for(i=0;i<the_set[pos].length;i++){      j = ((the_set[pos].example)[i]).index;      if(0 != Var[j]){	((the_set[pos].example)[i]).att = (((the_set[pos].example)[i]).att - Exp[j])/Var[j];      }      else{	// shouldn't happen!	((the_set[pos].example)[i]).att = 0; //  x - Exp = 0      };    };    if(0 != Var[dim]){      the_set[pos].y = (the_set[pos].y-Exp[dim])/Var[dim];    }    else{      the_set[pos].y -= Exp[dim]; // don't know if to scale ys, so Exp could be 0 or y    };  };  has_scale = 1;};void example_set_c::put_Exp_Var(SVMFLOAT *newExp, SVMFLOAT* newVar){  // precondition: dim is ok  if((newExp == 0) || (newVar == 0)){ return; };  if(Exp==0) Exp = new SVMFLOAT[dim+1];  if(Var==0) Var = new SVMFLOAT[dim+1];  SVMINT i;  for(i=0;i<=dim;i++){    Exp[i] = newExp[i];    Var[i] = newVar[i];  };};void example_set_c::scale(SVMFLOAT *theconst, SVMFLOAT *thefactor,SVMINT scaledim){  if((theconst == 0) || (thefactor == 0)) return;  if(scaledim>dim) set_dim(scaledim);  if(Exp==0) Exp = new SVMFLOAT[dim+1];  if(Var==0) Var = new SVMFLOAT[dim+1];  SVMINT i;  for(i=0;i<scaledim;i++){    Exp[i] = theconst[i];    Var[i] = thefactor[i];  };  for(i=scaledim;i<dim;i++){    Exp[i] = 0;    Var[i] = 0;  };  Exp[dim] = theconst[scaledim];  Var[dim] = thefactor[scaledim];  do_scale();};SVMFLOAT example_set_c::unscale_y(const SVMFLOAT scaled_y){  if((0 == Exp) || (0 == Var)){    return scaled_y;  }  else if(0 == Var[dim]){    return scaled_y+Exp[dim];  }  else{    return (scaled_y*Var[dim]+Exp[dim]);  };};void example_set_c::permute(){  // permute the examples  //  srand((unsigned int)time(0));  svm_example dummy;  SVMINT swap_pos;  SVMINT pos;  for(pos=0;pos<capacity-1;pos++){    swap_pos = (SVMINT)((SVMFLOAT)(pos+1)*rand()/(RAND_MAX+1.0));    dummy = the_set[swap_pos];    the_set[swap_pos] = the_set[pos];    the_set[pos] = dummy;  };  SVMINT i;  SVMINT the_size;  if(all_alphas != 0){    the_size = size();    for(i=0;i<the_size;i++){      all_alphas[i] = get_alpha(i);    };  };  if(all_ys != 0){    the_size = size();    for(i=0;i<the_size;i++){      all_ys[i] = get_y(i);    };  };};void example_set_c::clear_alpha(){

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产麻豆视频一区二区| 午夜成人在线视频| 成人免费毛片片v| 中文字幕成人av| 成人午夜碰碰视频| 成人免费小视频| 欧美亚洲高清一区| 日本不卡的三区四区五区| 精品日韩欧美在线| 国产精品99久久久久| 亚洲天堂免费看| 欧美日韩一区三区四区| 日韩精品一级中文字幕精品视频免费观看 | 久久久亚洲精品石原莉奈| 国产成人免费视频一区| 亚洲欧洲成人精品av97| 欧美日韩在线一区二区| 精品一区二区在线观看| 国产精品福利一区二区三区| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | heyzo一本久久综合| 亚洲精品国产精华液| 日韩丝袜情趣美女图片| 激情综合一区二区三区| 国产精品三级电影| 在线免费一区三区| 美国三级日本三级久久99| 久久久久久一二三区| 色偷偷久久人人79超碰人人澡| 亚洲香蕉伊在人在线观| 2020国产精品久久精品美国| 色欧美片视频在线观看在线视频| 亚洲第一电影网| 中文字幕巨乱亚洲| 欧美精品在线一区二区三区| 国产高清精品在线| 亚洲男同性恋视频| 精品sm捆绑视频| 色婷婷激情久久| 国产成人免费在线观看不卡| 亚洲午夜精品17c| 国产精品久久午夜| 日韩欧美中文一区| 色狠狠色狠狠综合| 高清av一区二区| 秋霞午夜鲁丝一区二区老狼| 依依成人精品视频| 久久久精品人体av艺术| 91精品国产色综合久久久蜜香臀| 成人av一区二区三区| 久久草av在线| 偷窥少妇高潮呻吟av久久免费| 国产精品蜜臀在线观看| 精品国产精品网麻豆系列| 欧美日韩视频一区二区| 99热精品国产| 高清av一区二区| 国产精品亚洲视频| 久久精品国产精品青草| 日韩av一区二区三区| 一区二区三区欧美亚洲| 亚洲国产电影在线观看| 精品国免费一区二区三区| 欧美日韩国产大片| 在线观看91视频| 色天天综合久久久久综合片| 国产成a人亚洲| 国产精品99久久久久久久vr| 久久99精品久久久久婷婷| 亚洲大片免费看| 亚洲一区在线观看视频| 一区二区三区久久久| 亚洲精品亚洲人成人网| 综合久久国产九一剧情麻豆| 国产精品久久久99| 国产精品国产自产拍高清av王其 | 精品视频1区2区3区| 91麻豆国产精品久久| 波多野结衣91| 99免费精品视频| 99re热视频精品| www.成人网.com| 色丁香久综合在线久综合在线观看| 91在线观看下载| 色婷婷激情一区二区三区| 欧洲av一区二区嗯嗯嗯啊| 欧洲人成人精品| 91精品午夜视频| 精品日韩在线观看| 国产亚洲精品超碰| 国产精品成人免费 | 亚洲18女电影在线观看| 日韩中文字幕不卡| 精品一二三四区| 成人av影院在线| 在线观看免费一区| 日韩一卡二卡三卡四卡| 久久久久久久久蜜桃| 亚洲国产精品激情在线观看| 亚洲欧洲av一区二区三区久久| 亚洲精品一二三四区| 日本午夜一本久久久综合| 精品亚洲免费视频| 99国产精品久久| 91精品免费在线观看| 国产校园另类小说区| 国产精品乱码久久久久久| 亚洲综合色在线| 久久国产精品色| voyeur盗摄精品| 5566中文字幕一区二区电影| 国产日韩在线不卡| 亚洲专区一二三| 国内精品免费**视频| 91免费视频观看| 日韩午夜激情视频| 亚洲图片你懂的| 精品亚洲成av人在线观看| 色综合久久66| 精品久久久网站| 亚洲一区二区三区四区五区中文| 久久国产生活片100| 91亚洲精品久久久蜜桃| 91精品国产综合久久久久久漫画 | 国产在线精品视频| 色综合天天综合网天天狠天天 | 国产精品传媒在线| 日韩国产高清影视| eeuss影院一区二区三区| 欧美日韩不卡在线| 国产精品乱码人人做人人爱 | 久久国产福利国产秒拍| 91麻豆文化传媒在线观看| 欧美一区二区免费视频| 亚洲美女精品一区| 国产酒店精品激情| 91精品国产综合久久久蜜臀粉嫩| 亚洲色图视频免费播放| 国产主播一区二区| 欧美一区二区视频观看视频| 亚洲特级片在线| 韩国成人福利片在线播放| 欧美日韩一区成人| 国产精品妹子av| 狠狠色丁香久久婷婷综| 欧美三区在线观看| ...av二区三区久久精品| 国模套图日韩精品一区二区| 91麻豆精品国产91久久久久久| 一区二区三区四区不卡在线 | 欧美区一区二区三区| 亚洲精选在线视频| 成人激情动漫在线观看| 精品国产91久久久久久久妲己| 亚洲第一搞黄网站| 91久久精品一区二区| 中文字幕一区二区三中文字幕| 国精产品一区一区三区mba桃花 | 成人激情视频网站| 国产香蕉久久精品综合网| 精品一区二区三区蜜桃| 56国语精品自产拍在线观看| 亚洲一二三专区| 欧美视频在线观看一区二区| 亚洲天堂免费看| 一本大道久久a久久精二百| 最新热久久免费视频| caoporen国产精品视频| 国产精品福利一区二区| 成人国产免费视频| 中文字幕制服丝袜一区二区三区| 成人小视频免费在线观看| 日本一区免费视频| 丰满白嫩尤物一区二区| 欧美高清在线精品一区| 99视频在线精品| 亚洲三级电影全部在线观看高清| 97aⅴ精品视频一二三区| 亚洲三级在线观看| 欧美亚洲动漫另类| 日韩专区中文字幕一区二区| 日韩一级视频免费观看在线| 青青草原综合久久大伊人精品优势| 日韩一区二区三区免费观看| 九一九一国产精品| 国产午夜亚洲精品羞羞网站| 成人av免费在线观看| 亚洲精品成a人| 欧美中文字幕一区| 另类欧美日韩国产在线| 久久久99久久精品欧美| av在线播放成人| 亚洲午夜激情网站| 精品国产欧美一区二区| 成人免费看视频| 亚洲一区二区三区小说| 欧美不卡一区二区| 国产91精品精华液一区二区三区| 亚洲天堂a在线| 91精品国产高清一区二区三区蜜臀|