我正在努力训练神经网络
Ptr< ANN_MLP > nn = ANN_MLP::create();
nn->setActivationFunction(cv::ml::ANN_MLP::SIGMOID_SYM);
nn->setTrainMethod(cv::ml::ANN_MLP::BACKPROP);
nn->setBackpropMomentumScale(0.1);
nn->setBackpropWeightScale(0.1);
nn->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, (int)100000, 1e-6));
//setting the NN layer size
cv::Mat layers = cv::Mat(3, 1, CV_32SC1);
layers.row(0) = cv::Scalar(4);
layers.row(1) = cv::Scalar(10);
layers.row(2) = cv::Scalar(16);
//layers.row(3) = cv::Scalar(16);
nn->setLayerSizes(layers);
nn->train(train_data, ROW_SAMPLE, response);
cout << "Hari";
while (1){}
waitKey(0);
return 0;
trainData是105735 * 4矩阵,而响应是105735 * 16矩阵。
以下错误即将来临: BTP.exe中0x00007FFA81ECA1C8处的未处理异常:Microsoft C ++异常:cv ::内存位置0x000000322AA5D820的异常。
错误是:
OpenCV错误:在cv :: ml中断言失败((layout == ROW_SAMPLE&amp;&amp; responses.rows == nsamples)||(layout == COL_SAMPLE&amp;&amp; respon.cols == nsamples)): :TrainDataImpl :: setData,文件C:\ builds \ master_PackSlave-win64-vc12-shared \ opencv \ modules \ ml \ src \ data.cpp,第290行