# Perceptron learning algorithm?

1. Sep 14, 2007

### Math Is Hard

Staff Emeritus
Have you ever written a perceptron learning algorithm?

http://en.wikipedia.org/wiki/Perceptron

Which language did you use? Would it be overly complicated to try to write it in C++ (compared with, say, MATLAB)?

2. Sep 17, 2007

### alastor

Hello,

yes, I have. I wrote it in C++ and it was not so hard. Simple perceptron is not very hard problem. Harder ist to write backprogation algorithm for a forward or recurent neural network.

3. Sep 18, 2007

### Math Is Hard

Staff Emeritus
Thanks for your reply. I am still trying to work it out on paper, and now I can see how a program that is specialized for matrices could have an advantage over implementing it in C++.

I have been trying to diagram out a simple two-input perceptron that will take a training set to learn the logic for OR, but I have been getting stuck. If I can't figure it out in a couple of days, I'll put up a diagram and some pseudocode and maybe you could help me figure out where I am going wrong. I agree - this should be simple!!!

4. Sep 22, 2007

### Math Is Hard

Staff Emeritus
I think I have gotten the thing worked out and written up in C++. The part that was tripping me up was figuring out how to use my array of four delta values (desired output minus actual output), along with the training set inputs, to go back and update the two weights, but I think I have that sorted out now.

Here is some output from a run that starts with weight values of 2 and -2 and a bias of -1.

My training input set looks like this:
0 0
1 0
0 1
1 1

I am surprised at how fast the weights "settle down" to values that work.

5. Sep 22, 2007

### Hurkyl

Staff Emeritus
Coding up artificial intelligence is really neat when it works.

6. Sep 22, 2007

### Math Is Hard

Staff Emeritus
I've looked at the course websites for various AI classes and some of the projects they do look really fun. One team had created a program that took scanned pieces of a jigsaw puzzle and put them together. I thought that was very cool!

7. Apr 8, 2011