xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 4KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-05
  • 語言: C/C++
  • 標簽:

資源簡介

adaboost源碼,用c++寫的。拋開了積分圖計算等復雜的部分,專注于adaboost算法的具體實現過程,希望對初學者有幫助,也希望高手不吝指教。

資源截圖

代碼片段和文件信息

/*初學adaboost,希望能和大家交流?QQ:358807915
email:smile_spring@yeah.net
*/


#include?
#include?
#include?
#include
#include?
using?std::vector?;
using?namespace?std;
#define?FCOUNT?100//特征數
#define?CCOUNT?30//弱分類器個數
#define?PCOUNT?200//正樣本數
#define?NCOUNT?300//負樣本數

struct?sample
{
int?features[FCOUNT];//特征
int?pos_neg;//正0,負1
float?weight;//權值
int?result;//分類器的識別結果

};
struct?weakClassifier
{
int?indexF;
float?threshold;
};
struct?MySortFunction
{
????int?m_n;
????MySortFunction(int?n):m_n(n)
????{
????}
????bool?operator()(sample&s1sample&s2)const
????{
????????return?s1.features[m_n]????}
};
//創建正樣本
void?CreatePos(vector&a)
{
int?ij;
???for(i=0;i {
sample?temp;
temp.pos_neg=0;
temp.weight=(float)1/(2*PCOUNT);
temp.result?=0;
for(j=0;j temp.features[j]=rand()%10;
a.push_back(temp);
}
}
float?min(float?afloat?b)
{
return(a<=b?a:b);
}
//創建負樣本
void?CreateNeg(vector&a)
{
int?ij;
for(i=0;i {
sample?temp;
temp.pos_neg=1;
temp.weight=(float)1/(2*NCOUNT);
temp.result?=1;
for(j=0;j temp.features[j]=rand()%10;
a.push_back(temp);
}
}
//Training?classifier
void?Training(vector&avector&bfloat*factors)
{
int?ij;
vector::size_type?id=0tcount=a.size();
for(i=0;i {
weakClassifier?temp;
????float?totalWeights=0.0totalPos=0.0totalNeg=0.0bPos=0bNeg=0;//(當前樣本之前的)正負樣本權值和
float?ethrbesterr=1.0;//訓練單個分類器時用到的錯誤率,閾值,最小錯誤率
float?FThr[FCOUNT];//特征閾值
float?minErr=1.0;//所有特征的最小錯誤率
????float?beta;//更新權值所需系數
/*權重歸一化*/
for(id=0;id {

評論

共有 條評論

相關資源