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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? svm_nu.cpp

?? svm算法的實現(xiàn)分類技術(shù)
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
  if(new_target < old_target){    KKTerror = 0;    //      target_count=0;    if(parameters->descend < old_target - new_target){      target_count=0;    }    else{      convError=1;    };    if(parameters->verbosity>=5){      cout<<"descend = "<<old_target-new_target<<"  ("<<old_target<<" --> "<<new_target<<")"<<endl;    };  }  else{    // nothing we can do    KKTerror=0;    convError=1;    if(parameters->verbosity>=5){      cout<<"WARNING: no descend ("<<old_target<<" -> "<<new_target<<"), stopping"<<endl;    };  };  if(convError){    target_count++;    if(new_target>=old_target){      for(i=0;i<working_set_size;i++){	primal[i] = qp.A[i]*all_alphas[working_set[i]];      };      };                                                                            if(parameters->verbosity>=5){	      cout<<"WARNING: Convergence error, setting sigfig = "<<sigfig_max<<endl;    };  };  if(target_count>50){    // non-recoverable numerical error    feasible_epsilon=1;    convergence_epsilon*=2;    if(parameters->verbosity>=1)      cout<<"WARNING: reducing KKT precision to "<<convergence_epsilon<<endl;    target_count=0;  };  if(parameters->verbosity>=5){	    cout<<"Resulting values:"<<endl;    for(i=0;i<working_set_size;i++){      cout<<i<<": "<<primal[i]<<endl;    };  };  time_optimize += get_time() - time_start;};void svm_nu_regression_c::print_special_statistics(){  // calculate tube size epsilon  SVMFLOAT b = examples->get_b();  SVMFLOAT epsilon_pos = 0;  SVMFLOAT epsilon_neg = 0;  SVMINT pos_count = 0;  SVMINT neg_count = 0;  SVMINT i;  for(i=0;i<examples_total;i++){    if((all_alphas[i] > is_zero) && (all_alphas[i]-Cpos<-is_zero)){      epsilon_neg += all_ys[i]-sum[i]-b;      neg_count++;    }    else if((all_alphas[i] <- is_zero) && (all_alphas[i]+Cneg>+is_zero)){      epsilon_pos += -all_ys[i]+sum[i]+b;      pos_count++;    };  };  if((parameters->Lpos == parameters->Lneg) ||     (pos_count == 0) ||     (neg_count == 0)){    // symmetrical    epsilon_pos += epsilon_neg;    pos_count += neg_count;    if(pos_count>0){      epsilon_pos /= (SVMINT)pos_count;      cout<<"epsilon = "<<epsilon_pos<<endl;    }    else{      cout<<"ERROR: could not calculate epsilon."<<endl;      cout<<pos_count<<"\t"<<neg_count<<endl; // @@@@@@@    };  }  else{    // asymmetrical    epsilon_pos /= (SVMINT)pos_count;    cout<<"epsilon+ = "<<epsilon_pos<<endl;    epsilon_neg /= (SVMINT)neg_count;    cout<<"epsilon- = "<<epsilon_pos<<endl;  };};/** * * svm_nu_pattern_c * **/SVMFLOAT svm_nu_pattern_c::nabla(const SVMINT i){  if(all_ys[i] > 0){    return( sum[i]);  }  else{    return(-sum[i]);  };};void svm_nu_pattern_c::init(kernel_c* new_kernel, parameters_c* new_parameters){  new_parameters->realC = 1;  svm_nu_regression_c::init(new_kernel,new_parameters);};void svm_nu_pattern_c::init_optimizer(){  // Cs are dived by examples_total in init_optimizer  svm_nu_regression_c::init_optimizer();  SVMINT i;  for(i=0;i<working_set_size;i++){    qp.l[i] = 0;  };};void svm_nu_pattern_c::update_working_set(){  svm_c::update_working_set();  SVMINT i;  for(i=0;i<working_set_size;i++){    if(qp.A[i]>0){      qp.c[i] += all_ys[working_set[i]];    }    else{      qp.c[i] -= all_ys[working_set[i]];    };  };};void svm_nu_pattern_c::init_working_set(){  // calculate nu-sum   if(examples->initialised_alpha()){    project_to_constraint();  };  sum_alpha_nu=0;  SVMFLOAT the_nu_sum = 0;  SVMFLOAT the_sum=0;  SVMINT pos_count=0;  SVMINT neg_count=0;  SVMINT ni;  for(ni=0;ni<examples_total;ni++){    the_sum += all_alphas[ni];    the_nu_sum += abs(all_alphas[ni]);    if(is_alpha_neg(ni)> 0){      neg_count++;    }    else{      pos_count++;    };  };  if((abs(the_sum) > is_zero) || (abs(the_nu_sum-nu) > is_zero)){    // set initial feasible point    // neg alpha: -nu/2n    // pos alpha:  nu/2p    if((nu*(SVMFLOAT)examples_total>2*(SVMFLOAT)pos_count) ||       (nu*(SVMFLOAT)examples_total>2*(SVMFLOAT)neg_count)){      nu = 2*((SVMFLOAT)pos_count)/((SVMFLOAT)examples_total);      if(nu > 2*((SVMFLOAT)neg_count)/((SVMFLOAT)examples_total)){	nu = 2*((SVMFLOAT)neg_count)/((SVMFLOAT)examples_total);      };      nu -= is_zero; // just to make sure      cout<<"ERROR: nu too large, setting nu = "<<nu<<endl;    };    for(ni=0;ni<examples_total;ni++){      if(is_alpha_neg(ni)> 0){	examples->put_alpha(ni,nu/(2*(SVMFLOAT)neg_count));      }      else{	examples->put_alpha(ni,-nu/(2*(SVMFLOAT)pos_count));      };    };    examples->set_initialised_alpha();  };  svm_c::init_working_set();};void svm_nu_pattern_c::print_special_statistics(){  // calculate margin rho  SVMFLOAT b = examples->get_b();  SVMFLOAT rho_pos = 0;  SVMFLOAT rho_neg = 0;  SVMINT pos_count = 0;  SVMINT neg_count = 0;  SVMINT i;  for(i=0;i<examples_total;i++){    if((all_alphas[i] > is_zero) && (all_alphas[i]-Cpos<-is_zero)){      rho_neg += sum[i]+b;      neg_count++;    }    else if((all_alphas[i] <- is_zero) && (all_alphas[i]+Cneg>+is_zero)){      rho_pos += -sum[i]-b;      pos_count++;    };  };  if((parameters->Lpos == parameters->Lneg) ||     (pos_count == 0) ||     (neg_count == 0)){    // symmetrical    rho_pos += rho_neg;    pos_count += neg_count;    if(pos_count>0){      rho_pos /= (SVMINT)pos_count;      cout<<"margin = "<<rho_pos<<endl;    }    else{      cout<<"ERROR: could not calculate margin."<<endl;    };  }  else{    // asymmetrical    rho_pos /= (SVMINT)pos_count;    cout<<"margin+ = "<<rho_pos<<endl;    rho_neg /= (SVMINT)neg_count;    cout<<"margin- = "<<rho_pos<<endl;  };};/** * * svm_distribution_c * **/int svm_distribution_c::is_alpha_neg(const SVMINT i){  // variable i is alpha*  return 1;};SVMFLOAT svm_distribution_c::nabla(const SVMINT i){  return( sum[i]);};SVMFLOAT svm_distribution_c::lambda(const SVMINT i){  // size lagrangian multiplier of the active constraint  SVMFLOAT alpha;  SVMFLOAT result = 0;  alpha=all_alphas[i];  if(alpha>is_zero){    // alpha*    if(alpha-Cneg >= - is_zero){      // upper bound active      result = -lambda_eq-sum[i];    }    else{      result = -abs(sum[i]+lambda_eq);    };  }  else{    // lower bound active    result = sum[i] + lambda_eq;  };  return result;};int svm_distribution_c::feasible(const SVMINT i){  // is direction i feasible to minimize the target function  // (includes which_alpha==0)  if(at_bound[i] >= shrink_const){ return 0; };  SVMFLOAT alpha;  SVMFLOAT result;  alpha=all_alphas[i];  if(alpha-Cneg >= - is_zero){    // alpha* at upper bound    result = -lambda_eq - sum[i];    if(result>=-feasible_epsilon){      return 0;     };  }  else if(alpha<=is_zero){    // lower bound active    result = sum[i]+lambda_eq;    if(result>=-feasible_epsilon){      return 0;     };  }  else{    // not at bound    result= abs(sum[i]+lambda_eq);    if(result<=feasible_epsilon){      return 0;     };  };  return 1;};int svm_distribution_c::feasible(const SVMINT i, SVMFLOAT* the_nabla, SVMFLOAT* the_lambda, int* atbound){  // is direction i feasible to minimize the target function  // (includes which_alpha==0)  int is_feasible=1;  if(at_bound[i] >= shrink_const){ is_feasible = 0; };  SVMFLOAT alpha;  alpha=all_alphas[i];  *the_nabla = sum[i];  if(alpha >= Cneg){ //alpha-Cneg >= - is_zero){    // alpha* at upper bound    *atbound = 1;    *the_lambda = -lambda_eq - *the_nabla; //sum[i] + 1;    if(*the_lambda >= 0){      at_bound[i]++;      if(at_bound[i] == shrink_const) to_shrink++;    }    else{      at_bound[i] = 0;    };  }  else if(alpha <= 0){    // lower bound active    *atbound = -1;    *the_lambda = lambda_eq + *the_nabla; //sum[i] + 1;    if(*the_lambda >= 0){      at_bound[i]++;      if(at_bound[i] == shrink_const) to_shrink++;    }    else{      at_bound[i] = 0;    };  }  else{    // not at bound    *atbound = 0;    *the_lambda = -abs(*the_nabla+lambda_eq);    at_bound[i] = 0;  };  if(*the_lambda >= feasible_epsilon){    is_feasible = 0;   };  return is_feasible;};void svm_distribution_c::init(kernel_c* new_kernel, parameters_c* new_parameters){  new_parameters->realC = 1;  nu = new_parameters->nu;  convergence_epsilon = 1e-4;  svm_pattern_c::init(new_kernel,new_parameters);  //  is_pattern = 1;};void svm_distribution_c::init_optimizer(){  // Cs are dived by examples_total in init_optimizer  svm_pattern_c::init_optimizer();};void svm_distribution_c::project_to_constraint(){  SVMINT total = 0;  SVMFLOAT alpha_sum=sum_alpha-nu;  SVMFLOAT alpha=0;  SVMINT i;  for(i=0;i<examples_total;i++){    alpha = all_alphas[i];    alpha_sum += alpha;    if((alpha>is_zero) && (alpha-Cneg < -is_zero)){      total++;    };  };  if(total>0){    // equality constraint violated    alpha_sum /= (SVMFLOAT)total;    for(i=0;i<examples_total;i++){      if((alpha>is_zero) && (alpha-Cneg < -is_zero)){	all_alphas[i] -= alpha_sum;      };    };  };};int svm_distribution_c::convergence(){  long time_start = get_time();  SVMFLOAT the_lambda_eq = 0;  SVMINT total = 0;  SVMFLOAT alpha_sum=0;  SVMFLOAT alpha=0;  SVMINT i;  int result=1;  // actual convergence-test  total = 0; alpha_sum=0;  //  cout<<Cneg<<"\t"<<nu<<"\t"<<all_alphas[0]<<endl;  for(i=0;i<examples_total;i++){    alpha = all_alphas[i];    alpha_sum += alpha;    if((alpha>is_zero) && (alpha-Cneg < -is_zero)){      // alpha^* = - nabla      the_lambda_eq += -sum[i];      total++;    };  };  if(parameters->verbosity>= 4){    cout<<"lambda_eq = "<<(the_lambda_eq/total)<<endl;  };  if(total>0){    lambda_eq = the_lambda_eq / total;  }  else{    // keep WS lambda_eq    lambda_eq = lambda_WS;    if(parameters->verbosity>= 4){      cout<<"*** no SVs in convergence(), lambda_eq = "<<lambda_eq<<"."<<endl;    };  };  if(target_count>2){    if(target_count>20){      // desperate!      lambda_eq = ((40-target_count)*lambda_eq + (target_count-20)*lambda_WS)/20;      if(parameters->verbosity>=5){	cout<<"Re-Re-calculated lambda from WS: "<<lambda_eq<<endl;      };      if(target_count>40){	// really desperate, kick one example out!	i = working_set[target_count%working_set_size];	lambda_eq = -sum[i];	if(parameters->verbosity>=5){	  cout<<"set lambda_eq to nabla("<<i<<"): "<<lambda_eq<<endl;	};      };    }    else{      lambda_eq = lambda_WS;      if(parameters->verbosity>=5){	cout<<"Re-calculated lambda_eq from WS: "<<lambda_eq<<endl;      };    };  };  // check linear constraint  if(abs(alpha_sum+sum_alpha-nu) > convergence_epsilon){    // equality constraint violated    if(parameters->verbosity>= 4){      cout<<"No convergence: equality constraint violated: |"<<(alpha_sum+sum_alpha)<<"| >> 0"<<endl;    };    project_to_constraint();    result = 0;    };  i=0;  while((i<examples_total) && (result != 0)){    if(lambda(i)>=-convergence_epsilon){      i++;    }    else{      result = 0;    };  };  time_convergence += get_time() - time_start;  return result;};void svm_distribution_c::init_working_set(){  // calculate sum  SVMINT i,j;  if(nu>1){    cout<<"ERROR: nu too large, setting nu to 1"<<endl;    nu = 1-is_zero;  };  SVMFLOAT the_sum=0;  for(i=0; i<examples_total;i++){    the_sum += all_alphas[i];  };  if(abs(the_sum-nu) > is_zero){    for(i=0; i<examples_total;i++){      examples->put_alpha(i,nu/((SVMFLOAT)examples_total));    };    examples->set_initialised_alpha();  };  if(parameters->verbosity >= 3){    cout<<"Initialising variables, this may take some time."<<endl;  };  for(i=0; i<examples_total;i++){    all_ys[i] = 1;    sum[i] = 0;    at_bound[i] = 0;    for(j=0; j<examples_total;j++){      sum[i] += all_alphas[j]*kernel->calculate_K(i,j);    };  };  calculate_working_set();  update_working_set();};void svm_distribution_c::print_special_statistics(){  // calculate margin rho  SVMFLOAT rho = 0;  SVMINT count = 0;  SVMFLOAT norm_x;  SVMFLOAT max_norm_x=-infinity;  //  SVMFLOAT xi_i;  //  SVMINT estim_loo=examples_total;  //  SVMINT estim_loo2=examples_total;  SVMINT svs=0;  SVMINT i;  for(i=0;i<examples_total;i++){    if((all_alphas[i] > is_zero) && (all_alphas[i]-Cpos<-is_zero)){      rho += sum[i];      count++;    };    if(all_alphas[i] != 0){      svs++;      norm_x = kernel->calculate_K(i,i);      if(norm_x>max_norm_x){	max_norm_x = norm_x;      };    };  };  if(count == 0){    cout<<"ERROR: could not calculate margin."<<endl;  }  else{    // put -rho as b (same decision function)    rho /= (SVMINT)count;    examples->put_b(-rho);    cout<<"margin = "<<rho<<endl;  };  cout<<"examples in distribution support : "<<count<<" ("<<((SVMINT)(10000.0*(SVMFLOAT)count/((SVMFLOAT)examples_total)))/100.0<<"%)."<<endl;};

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美女视频黄免费的久久| 国产精品家庭影院| 久久疯狂做爰流白浆xx| 91精品久久久久久久久99蜜臂| 日韩福利视频网| 日韩欧美国产精品一区| 国产在线精品一区二区夜色| 久久亚洲精品国产精品紫薇| 国产成人精品影院| 亚洲精品日韩综合观看成人91| 91浏览器在线视频| 日韩电影在线免费看| 精品国精品国产尤物美女| 国产一本一道久久香蕉| 国产精品久久久久婷婷二区次| 色欧美片视频在线观看在线视频| 日韩高清电影一区| 日本一区二区三区国色天香 | 久久久久久9999| 国产精品自拍三区| 伊人色综合久久天天人手人婷| 欧美群妇大交群的观看方式| 国产毛片精品视频| 一区二区三区四区国产精品| 欧美一区二区三区免费观看视频| 国产高清一区日本| 亚州成人在线电影| 国产无遮挡一区二区三区毛片日本| 色综合天天在线| 麻豆精品一区二区| 一区二区三区成人| 久久综合久久久久88| 欧美三级电影网站| 丁香激情综合国产| 日韩av一二三| 一片黄亚洲嫩模| 久久久久久久久岛国免费| 欧美在线小视频| 国产盗摄一区二区三区| 日韩vs国产vs欧美| 亚洲精品成a人| 国产日韩欧美亚洲| 日韩午夜中文字幕| 在线看国产一区二区| 国产91富婆露脸刺激对白| 免费的成人av| 视频在线在亚洲| 亚洲精品免费在线播放| 久久久www免费人成精品| 91麻豆精品国产| 色妹子一区二区| 国产中文一区二区三区| 蜜臀久久99精品久久久画质超高清 | 国产一区二区视频在线| 午夜伊人狠狠久久| 亚洲欧美日韩系列| 国产精品久久久久三级| 久久精品夜色噜噜亚洲a∨| 91精品国产91热久久久做人人| 91麻豆swag| 色婷婷综合在线| a在线欧美一区| 国产成人在线视频播放| 精品写真视频在线观看| 蜜臀91精品一区二区三区| 日韩精品一二三四| 午夜精品久久久久久久久久久 | 亚洲乱码精品一二三四区日韩在线| 337p日本欧洲亚洲大胆精品| 欧美大片免费久久精品三p| 91精品婷婷国产综合久久竹菊| 欧美午夜精品久久久久久超碰| 色视频成人在线观看免| 99久久777色| 99精品视频在线观看| 高清不卡一二三区| youjizz久久| 91美女在线观看| 欧洲国内综合视频| 欧美午夜影院一区| 欧美久久久久久久久中文字幕| 69精品人人人人| 91精品国产91久久综合桃花| 日韩视频免费观看高清在线视频| 欧美情侣在线播放| 欧美一级片在线看| 26uuu国产在线精品一区二区| xvideos.蜜桃一区二区| 久久久久国产成人精品亚洲午夜 | 成人网在线免费视频| 91亚洲精品久久久蜜桃网站| 日本韩国欧美三级| 欧美精品在线视频| 久久久久久日产精品| 国产精品卡一卡二卡三| 亚洲婷婷综合色高清在线| 亚洲午夜av在线| 美女一区二区三区| 成人国产精品免费观看视频| eeuss鲁一区二区三区| 欧美伊人精品成人久久综合97 | 久久久www免费人成精品| 中文字幕中文字幕一区二区| 亚洲精品菠萝久久久久久久| 免费成人在线播放| 成人av综合在线| 欧美探花视频资源| 久久综合一区二区| 亚洲精品成人天堂一二三| 免费观看日韩av| 91一区在线观看| 91精品国产综合久久久久久久 | 精品免费视频.| 自拍偷拍亚洲综合| 热久久久久久久| av在线一区二区| 日韩一区二区三区四区| 亚洲视频网在线直播| 久久se这里有精品| 色94色欧美sute亚洲线路一久 | 免费三级欧美电影| 91丨九色丨尤物| 久久综合色天天久久综合图片| 亚洲欧洲三级电影| 久久99精品一区二区三区三区| 91农村精品一区二区在线| 日韩三级精品电影久久久| 国产精品久久久久久久久免费相片 | 91亚洲永久精品| 精品国产一区二区三区久久影院| 亚洲视频在线一区| 国产夫妻精品视频| 在线综合+亚洲+欧美中文字幕| 亚洲国产精品国自产拍av| 一区二区三区不卡视频在线观看| 捆绑调教一区二区三区| 欧美婷婷六月丁香综合色| 亚洲国产精品av| 精品无人码麻豆乱码1区2区| 在线免费观看成人短视频| 日本一区二区免费在线观看视频| 亚洲国产色一区| 不卡一区二区三区四区| 久久午夜电影网| 蜜芽一区二区三区| 在线不卡欧美精品一区二区三区| 1区2区3区精品视频| 粉嫩在线一区二区三区视频| 日韩欧美一级二级| 五月天亚洲婷婷| 欧美羞羞免费网站| 亚洲免费在线视频一区 二区| 国产成人久久精品77777最新版本| 日韩美女视频在线| 日本网站在线观看一区二区三区| 日本精品视频一区二区| 亚洲欧美中日韩| 国产91精品露脸国语对白| 久久综合中文字幕| 激情综合色丁香一区二区| 91超碰这里只有精品国产| 亚洲国产精品久久一线不卡| 91官网在线免费观看| 亚洲男人的天堂av| 色噜噜狠狠一区二区三区果冻| 中文字幕一区二区三区蜜月| 成人自拍视频在线| 中文字幕一区二区日韩精品绯色| 国产成人av影院| 国产精品三级av| 99精品视频在线观看| 中文字幕永久在线不卡| 91视频www| 一区二区三区精品在线观看| 日本精品免费观看高清观看| 亚洲第一久久影院| 欧美一级片在线| 国产福利91精品| 亚洲色图在线播放| 在线视频欧美区| 日本视频中文字幕一区二区三区| 欧美成人aa大片| 国产a区久久久| 亚洲免费在线视频一区 二区| 欧美视频在线不卡| 免费看欧美女人艹b| 久久久久久久久久久久久夜| 成人免费视频国产在线观看| 亚洲欧美日本在线| 欧美美女网站色| 国产一区不卡在线| 亚洲日本韩国一区| 91麻豆精品国产| 福利91精品一区二区三区| 一区二区三区在线观看欧美| 日韩欧美一区二区三区在线| 成人午夜电影小说| 亚洲国产精品综合小说图片区| 日韩精品中文字幕一区| 成人不卡免费av|