At the forefront of Artificial Intelligence
  Home Articles Reviews Interviews JDK Glossary Features Discussion Search
Home » Articles » Neural Networks » Projects

Perceptron 'OR' Project

Training a perceptron to learn the OR Logic gate is simple (and trivial!). Nevertheless, it is a great way to see how the Perceptron Learning Rule can be used.

Outline

For those of you that haven't read the Perceptron essay, please do so. For those of you that have, here is a little review. A perceptron will 'fire' (output is 1) if the net input (sum of the inputs multiplied by their weights) is greater than or equal to one. Otherwise the perceptron will not fire (output is 0). This is summed up by the equation below.

We then compare the output of the perceptron with the desired output, and adjust the weights accordingly.

Now, we are going to train the perceptron to learn the OR-logic gate. The truth table for the OR gate is as follows:

x1x2y
000
101
011
111

By visualizing the graph of the truth table, it is easy to see that the line separating the points could be y=-x+1. Any line though that passes between the origin and the (0,1)(1,1)(1,0) trio will suffice though.

Guidelines

It might be a good idea to print the results of the network during each (or even x number) training cycle to get a good look at how the perceptron learns. Also, the line that the perceptron uses to classify is equal to:

where w1 and w2 are the two weights, and b is the bias.

Note, that the OR logic gate was chosen simply because it is easy to see and debug. A single perceptron can classify any linearly separable data, therefore try testing your perceptron code with a multitude of data after it works with the OR gate.


Solutions

or.pda (26 bytes) Download PDA32 and the data file below. Place the data file in the same directory as PDA32, and run the program. Then select "or.pda" from the data combo box. The data will be graphed, then press Run to run the perceptron learning process.
cf-ai.zip (14 Kb) Craig Furness submitted this solution. His neural network tackles the harder problem of the XOR logic gate.

Submitted: 16/12/2001

Article content copyright © James Matthews, 2001.
 Article Toolbar
Print
BibTeX entry

Search

Latest News
- Generation5 10-year Anniversary (03/09/2008)
- New Generation5 Design! (09/04/2007)
- Happy New Year 2007 (02/01/2007)
- Where has Generation5 Gone?! (04/11/2005)
- NeuroEvolving Robotic Operatives (NERO) (25/06/2005)

What's New?
- Back-propagation using the Generation5 JDK (07/04/2008)
- Hough Transforms (02/01/2008)
- Kohonen-based Image Analysis using the Generation5 JDK (11/12/2007)
- Modelling Bacterium using the JDK (19/03/2007)
- Modelling Bacterium using the JDK (19/03/2007)


All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -