ANN prediction

asked 2013-05-20 14:18:11 -0600

ImageClassif75 gravatar image

updated 2013-05-20 14:36:43 -0600

berak gravatar image

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 flag offensive close merge delete

Comments

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

could you explain, where your results differ ?

berak gravatar imageberak ( 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)

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

I am using OpenCV 2.4.3 version.

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

ah, nice update !

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