December 01, 2013

Number recognition with neural network in LabVIEW

Introduction

I have a class about neural nets at the university, so I tried to program one for number recognition like this but in LabView. Then I realized: I didn't have enought knowledge for this, so I google neural networks and found this awesome course: https://www.coursera.org/course/neuralnets

So how it's working?

It has a recognition and a learning mode. As input the network get xij, an 8x8 boolean array with the pixels of the image. And there is wkij, the weight; a 3D integer array. It contains for all the 10 numbers (this is the first dimension) for all the pixels (2nd and 3rd dimension) the probability of this pixel is in the image of the number. If the pixel is always in the image, then it's a big positive number. If it's never there, it's big negative number.
In recognition mode it makes a sum of product for each numbers so: sumi=0->7( sumj=0->7( Xij*wkij)) (Xij is +1 if xij true, and -1 if xij false) and the result is a 1 D integer array yk. Then it looks for the maximum of the array y, and the index of the maximum is the result.

In learning mode it needs the image of a number, the number itself and from these information it calculates and changes the weight. It goes through all the numbers and for each number every pixel. If the number is equal the given number AND the pixel is true, then +10 to the weight, if pixel is false -10 to the weight for this case. If the number is NOT equal with the given one, AND the pixel is true, then -1 to the weight and +1 if the pixel is false. Train the system at least 2-3 image for each number, but the more image you train, the better result you get. But you have to use the same amount of image for each numbers, otherwise it will give back an incorrect result.

Result

It was also surprising for me, how good it works:
The code is available here

Best regards:

Mark

18 comments:

  1. Congrat, dude! I though, that you can do it! Next time, you should hack the captha-code here in the comment! :)

    ReplyDelete
  2. gud work .. saw this video in youtube,,could you please upload an older version of dis vi..

    ReplyDelete
  3. great work

    congrats

    greetings from Cd Juarez Mexico

    ReplyDelete
  4. Nice work. I believe the link is no longer valid. Could you please update? Thanks!

    ReplyDelete
  5. Nice work. I believe the link is no longer valid. Could you please update? Thanks!

    ReplyDelete
    Replies
    1. Oh, sorry, OneDrive broke the link for some reason, I updated the post with the working link.

      Delete
  6. Nice work. I believe the link is no longer valid. Could you please update? Thanks!

    ReplyDelete

  7. the tutorial makes the program available, sir,,,/

    ReplyDelete
  8. the tutorial makes the program available, sir

    ReplyDelete
  9. First of all thanks for sharing your interesting work. I just find in youtube your video last night and I want to probe in LabView your code, but I am habing problems because in the learning part the Weight Local Variable dont save the values.
    I am using Lavbiew 2017, any idea about the problem??
    Thanks for your time.

    ReplyDelete
  10. I just found my error, I dont initialized the local variable Weight, sorry for my stupid question, now your code runs perfect, thanks for all. Its a practical and interesting form to understand how works the neural netwoorks.

    ReplyDelete
  11. Really nice work. The link for the code seems to be broken. Could you please share the code again?
    Thank you.

    ReplyDelete
  12. Very nice work. Amazed by the performance.
    Thanks a lot for sharing.

    ReplyDelete
    Replies
    1. The code isn't working for me it's showing either zero or one

      Delete
    2. Initialize the weight array initially by manual entry in front panel with 0 value

      Delete
  13. My recognition mode isn't working properly and is displaying only the first value can someone please help

    ReplyDelete