Commit 4997f5df authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #4174 from yangj1e:fix_svm_trainauto

parents 743160b6 2ba0d317
...@@ -1675,6 +1675,7 @@ public: ...@@ -1675,6 +1675,7 @@ public:
Mat samples = data->getTrainSamples(); Mat samples = data->getTrainSamples();
Mat responses; Mat responses;
bool is_classification = false; bool is_classification = false;
Mat class_labels0;
int class_count = (int)class_labels.total(); int class_count = (int)class_labels.total();
if( svmType == C_SVC || svmType == NU_SVC ) if( svmType == C_SVC || svmType == NU_SVC )
...@@ -1688,7 +1689,8 @@ public: ...@@ -1688,7 +1689,8 @@ public:
setRangeVector(temp_class_labels, class_count); setRangeVector(temp_class_labels, class_count);
// temporarily replace class labels with 0, 1, ..., NCLASSES-1 // temporarily replace class labels with 0, 1, ..., NCLASSES-1
Mat(temp_class_labels).copyTo(class_labels); class_labels0 = class_labels;
class_labels = Mat(temp_class_labels).clone();
} }
else else
responses = data->getTrainResponses(); responses = data->getTrainResponses();
...@@ -1821,6 +1823,7 @@ public: ...@@ -1821,6 +1823,7 @@ public:
} }
params = best_params; params = best_params;
class_labels = class_labels0;
return do_train( samples, responses ); return do_train( samples, responses );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment