Ask Your Question

SVM training error

asked 2014-10-08 04:44:32 -0500

annarose gravatar image

Now I train SVM with SURF feature for face recognition. During training I got an error like this:

OpenCV Error: Sizes of input arguments do not match (Response array must contain as many elements as the total number of samples) in cvPreprocessCategoricalResponses, file /home/arya/stuff/opencv/opencv-2.4.7/modules/ml/src/inner_functions.cpp, line 671 terminate called after throwing an instance of 'cv::Exception' what(): /home/arya/stuff/opencv/opencv-2.4.7/modules/ml/src/inner_functions.cpp:671: error: (-209) Response array must contain as many elements as the total number of samples in function cvPreprocessCategoricalResponses

I don't understand what this error exactly mean by.Could anyone explain me why I got error like this?

edit retag flag offensive close merge delete



for, say, 17 SURF features you should have a 17x128 trainData Mat, and a 17x1 trainLabels Mat

berak gravatar imageberak ( 2014-10-08 06:34:38 -0500 )edit

maybe you can show us, how you fill the labels ?

berak gravatar imageberak ( 2014-10-08 07:08:51 -0500 )edit

I gave +1 for positive images and -1 for negative images. Few examples are shown below. /home/arya/Images/OutputImage/im1.pgm;1 /home/arya/Images/OutputImage/im2.pgm;1 /home/arya/Images/OutputImage/im3.pgm;1 /home/arya/Images/OutputImage/im4.pgm;1 /home/arya/Images/OutputImage/im5.pgm;1 /home/arya/Images/OutputImage/im46.pgm;-1 /home/arya/Images/OutputImage/im47.pgm;-1 /home/arya/Images/OutputImage/im48.pgm;-1 /home/arya/Images/OutputImage/im49.pgm;-1 /home/arya/Images/OutputImage/im50.pgm;-1 /home/arya/Images/OutputImage/im51.pgm;-1 /home/arya/Images/OutputImage/im52.pgm;-1

annarose gravatar imageannarose ( 2014-10-08 22:18:07 -0500 )edit

Thank you..I solved my error. As you said, my problem is in trainData Mat and trainLabels Mat.

annarose gravatar imageannarose ( 2014-10-08 22:47:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-05-23 06:50:26 -0500

waschbaer gravatar image

It means the labels number should correspond to samples number.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2014-10-08 04:44:32 -0500

Seen: 848 times

Last updated: Oct 08 '14