# ANN prediction

I am using CvANN_MLP. When I call predict(), I don't get the same responses when I give all the data at once (1 row = vector) and when I make a loop and submit the vector one by one myself.

Here are my 2 solutions :

solution1 :

for (int z = 0; z<valid_data.rows; z++)
{
Mat sample = valid_data.row(z);
Mat result_test = Mat(1, 1, CV_32FC1);
ann.predict(sample, result_test);
result_.at<float>(z) = result_test.at<float>(0);
}


solution2 :

 float res = ann.predict(valid_data, result_);


They don't give the same result, but they sould right?

edit retag close merge delete

yes, they should. and i get the same result both ways here !

could you explain, where your results differ ?

( 2013-05-21 09:57:43 -0600 )edit

Hi Berak, Thank you for your reply. I get the same result for most cases, but for some rows, the response differs. For example, for the input data I have column1 for solution1 and column2 for solution2 :

Column1 Column2

1.80621 1.80621

1.80621 1.80621

1.80621 1.80621

1.80621 1.80621

1.80621 1.80621

1.80621 1.80621

1.80621 1.80621

-0.309371 -0.309371

1.80621 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 -0.309371

-0.309371 1.80621

1.80621 1.80621

-0.309371 1.80621

1.80621 1.80621

1.80621 1.80621

1.80621 1.80621

1.80621 1 ...(more)

( 2013-05-21 14:35:28 -0600 )edit

I am using OpenCV 2.4.3 version.

( 2013-05-21 14:44:18 -0600 )edit

ah, nice update !

( 2013-05-21 14:55:50 -0600 )edit