Ask Your Question
2

neural network for pattern recognition examples

asked 2013-09-05 22:30:57 -0600

rastayew gravatar image

how to use cvann_mlp for pattern recognition (how can i use images to create an xml file for input) + (how can i train and predict) i need a source code. thank you

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2013-09-07 02:51:19 -0600

berak gravatar image

to use a neural network ,

  • decide on the layout of the net :

    1. how many inputs do i want ? sending in a HD image with a million pixels is not reasonable, so you have to rescale it , reduce to grayscale, etc.
    2. it needs hidden layers. start with one, do tests, increase if nessecary.
    3. the number of outputs is the number of your classes
  • prepare the input data:

    1. the trainmatrix will be N rows (one per image) x M cols (number of pixels_per_image) you'll have to flatten your images to 1 row (reshape(1,1)), and convert to float, (probably normalize to [0..1]), finally assemble a Mat from those rows.
    2. the trainlabels, or responses will be a similar float Matrix with N rows (again, one per image) x M cols (the expected output layer per image) the highest 'score' per row should be for the expected classid

dummy example(5 images, 4 input pixels, 2 classes):

_data_      _labels_
2 4 5 3      0 1
4 3 2 3      0 1
1 1 5 1      1 0
1 2 5 3      1 0
1 2 2 2      1 0
  • now you can train your net, and save the trained state to xml/yml.
  • later, you can reload that, and do predictions on test images. you'll have to process them in the very same way as for the training, only difference is, you only got one row as input, and will receive one output row as result. the index of the highest score in that output is your predicted classid.
edit flag offensive delete link more

Comments

1

+1 for explaining the principle and not supplying a ready made code sample for copy past purposes :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-07 04:45:20 -0600 )edit
3

yea, definitely on purpose..

berak gravatar imageberak ( 2013-09-07 04:47:47 -0600 )edit

despite of my efforts there, feel free to close it (for being just another case of dumb begging-for-code), as i've seen no proper response from the original poster

berak gravatar imageberak ( 2013-09-08 16:40:48 -0600 )edit

I kind of keep the rule, that when there is at least a decent answer, I keep it open. Again this illustrates the owner doesn't need help solving it themselves but it can help others with problems.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-09 01:44:18 -0600 )edit

Question Tools

Stats

Asked: 2013-09-05 22:30:57 -0600

Seen: 1,682 times

Last updated: Sep 07 '13