具有大数据的OpenCV 3 SVM列车

时间:2015-07-06 14:10:51

标签: c++ machine-learning opencv3.0

我最近从OpenCV 2.4.6切换到3.0。 我的代码看起来像这样:

Ptr<ml::SVM> pSVM = ml::SVM::create();
pSVM->->setType(cv::ml::SVM::C_SVC);
pSVM->setKernel(cv::ml::SVM::LINEAR);
pSVM->->setC(1);

 cv::Ptr<cv::ml::TrainData> TrainData = cv::ml::TrainData::create(TrainMatrix, cv::ml::ROW_SAMPLE, Labels);
//TrainMatrix is a cv::Mat with 35000 rows and 1900 cols and float values in it. One Feature per row.
//Labels is a std::vector<int> with 35000 Elements with 1 and -1 in it.

   pSVM->trainAuto(TrainData, 10, cv::ml::SVM::getDefaultGrid(cv::ml::SVM::C), cv::ml::SVM::getDefaultGrid(cv::ml::SVM::GAMMA), cv::ml::SVM::getDefaultGrid(cv::ml::SVM::P),
            cv::ml::SVM::getDefaultGrid(cv::ml::SVM::NU), cv::ml::SVM::getDefaultGrid(cv::ml::SVM::COEF), cv::ml::SVM::getDefaultGrid(cv::ml::SVM::DEGREE), false);

当我的程序到达trainAuto方法崩溃时,在错误消息中表示它无法分配524395968字节。这个数字似乎有点高。在崩溃之前,程序在调试模式下消耗大约400 MB。

如果我在方法中放置一个较小的矩阵(大约500行),一切都正常运行。

是否有任何相同的问题,并知道解决方案?

0 个答案:

没有答案