Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thank You sir. I have chaged to type CV32FC1 and rearrange matrix (I forgot that in Matlab I use transpose), so now I have this code and it works. Once again thanks for Your help.

Mat_<int> layers(4,1,CV_16U);
layers(0) = 2;     // input
layers(1) = 100;  // hidden
layers(2) = 100;  // hidden
layers(3) = 1;      // output
ann_og->setLayerSizes(layers);
Mat trainData_tr;
transpose(trainData,trainData_tr);
ann_og->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM,0,0);
ann_og->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 300, 0.0001));
ann_og->setTrainMethod(ml::ANN_MLP::BACKPROP, 0.0001);
ann_og->train(trainData_tr, ml::COL_SAMPLE, trainClass);