Enforced DecisionFunction vector indexes to be saved on SVM save/load methods

pull/6345/head
Eduardo Arnold 9 years ago
parent ff0d115800
commit d046602ea4
  1. 6
      modules/ml/src/svm.cpp

@ -2092,7 +2092,7 @@ public:
<< "alpha" << "[:"; << "alpha" << "[:";
fs.writeRaw("d", (const uchar*)&df_alpha[df.ofs], sv_count*sizeof(df_alpha[0])); fs.writeRaw("d", (const uchar*)&df_alpha[df.ofs], sv_count*sizeof(df_alpha[0]));
fs << "]"; fs << "]";
if( class_count > 2 ) if( class_count >= 2 )
{ {
fs << "index" << "[:"; fs << "index" << "[:";
fs.writeRaw("i", (const uchar*)&df_index[df.ofs], sv_count*sizeof(df_index[0])); fs.writeRaw("i", (const uchar*)&df_index[df.ofs], sv_count*sizeof(df_index[0]));
@ -2234,11 +2234,11 @@ public:
df_index.resize(ofs + sv_count); df_index.resize(ofs + sv_count);
df_alpha.resize(ofs + sv_count); df_alpha.resize(ofs + sv_count);
dfi["alpha"].readRaw("d", (uchar*)&df_alpha[ofs], sv_count*sizeof(df_alpha[0])); dfi["alpha"].readRaw("d", (uchar*)&df_alpha[ofs], sv_count*sizeof(df_alpha[0]));
if( class_count > 2 ) if( class_count >= 2 )
dfi["index"].readRaw("i", (uchar*)&df_index[ofs], sv_count*sizeof(df_index[0])); dfi["index"].readRaw("i", (uchar*)&df_index[ofs], sv_count*sizeof(df_index[0]));
decision_func.push_back(df); decision_func.push_back(df);
} }
if( class_count <= 2 ) if( class_count < 2 )
setRangeVector(df_index, sv_total); setRangeVector(df_index, sv_total);
if( (int)fn["optimize_linear"] != 0 ) if( (int)fn["optimize_linear"] != 0 )
optimize_linear_svm(); optimize_linear_svm();

Loading…
Cancel
Save