Ask Your Question

Revision history [back]

SVMSGD classifier not working

I'm trying to use the SVMSGD classifier in OpenCV 3.3.1 but I'm struggling to get any kind of result. Here is an excerpt of the relevant code I am using right now.

cv::Ptr<cv::ml::SVMSGD> svm = cv::ml::SVMSGD::create();
svm->setOptimalParameters();

cv::Ptr<cv::ml::TrainData> tdata = cv::ml::TrainData::create(train_data, cv::ml::ROW_SAMPLE, truth_data);
svm->train(tdata);

svm->save("svmsgd.xml");

But even when I change the SVMSGD parameters the training is always almost instantaneous and the weights saved in the xml files are always all zeros. (and of course i get poor accuracy results) The other classifiers like the SVM work fine so there shouldn't be any problems with the data.