本文整理汇总了C++中DataList::get_size方法的典型用法代码示例。如果您正苦于以下问题:C++ DataList::get_size方法的具体用法?C++ DataList::get_size怎么用?C++ DataList::get_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataList
的用法示例。
在下文中一共展示了DataList::get_size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: train
/*******************************************************************************
* Function :
* Description :
* Arguments :
* Returns :
* Remarks :
********************************************************************************/
void AdaBoost::train ( POPULTATION& population, DataList & datalist ) {
cout << "boosting..." << population.size() << endl;
delta_M.resize(datalist.get_size(),1./datalist.get_size());
delta_w.resize(population.size(), 0.0);
delta_omega.resize(population.size(), 0.0);
alpha.resize((size_t)X);
rho.resize((size_t)X, 0.0);
vector<int> classifications(datalist.get_size(),0);
for ( int x = 0; x < X; x++ ) {
auto w = 0;
for ( auto&& creature : population ) {
auto m = 0;
auto tp = 0, fp = 0, fn = 0, tn = 0;
delta_w[w] = numeric_limits<double>::min();
for ( auto&& obj : datalist.get() ) {
Mat image = obj.get_image();
creature.perform_transforms(image);
creature.compute_output();
auto output = creature.get_output();
int label = (obj.get_label() == learning_label) ? 1 : 0;
classifications[m] = output;
if ( output != label ) {
delta_w[w] += delta_M[m];
}
if ( output == 1 && label == 1 )
{
tp++; // True positive = correctly identified
}
else if ( output == 1 && label == 0 )
{
fp++; // False positive = incorrectly identified
}
else if ( output == 0 && label == 1 )
{
fn++; // False negative = incorrectly rejected
}
else if ( output == 0 && label == 0 )
{
tn++; // True negative = correctly rejected
}
m++;
}
delta_omega[w] = (tp+tn)*1. / (tp+tn+fp+fn)*1.;
w++;
}
auto min_error = numeric_limits<double>::max();
auto omega = 0;
for ( w = 0; w < delta_w.size(); w++ ) {
if (delta_w[w] < min_error) {
min_error = delta_w[w];
omega = w;
}
}
if ( 1. - delta_omega[omega] >= 0.5 && delta_w[omega] > 1.0 ) {
X = x;
break;
}
rho[x] = 0.5 * log( (1 - delta_w[omega]) / delta_w[omega] );
alpha[x] = population[omega];
population.erase(population.begin()+omega);
delta_w.erase(delta_w.begin()+omega);
if ( population.empty() ) {
break;
}
auto m = 0;
auto N = 0.;
for ( auto&& obj : datalist.get() ) {
int label = (obj.get_label() == learning_label) ? 1 : 0;
auto c = (classifications[m] == label) ? 1 : -1;
delta_M[m] = (delta_M[m] * exp(-(rho[x] * c)));
N += delta_M[m];
m++;
}
for ( m = 0; m < datalist.get_size(); m++ ) {
delta_M[m] /= N;
m++;
}
}
//.........这里部分代码省略.........