Psychology 149
 Machine Learning & AI

Lab Project 4:  Back Propagation



1)  Without using Matlab neural net functions (such as feedforwardnet) create a neural network that uses back propagation to solve the XOR problem shown in the following Venn diagram.   The green regions show areas of the diagram that are in set A (first circle) or set B (second circle) but NOT both.  Solving the XOR problem means that when you give the input nodes (x1 and x2) of the network the values shown in the table below, the output of the network should be the value shown in the third column of the table (In logic, tables like this are sometimes referred to as the Truth Table).  So, for example, if we give input values to the network x1=0 and x2=1, the network's output should be 1.  



The network you create should have two input nodes (because we only have two values to give it, x1 and x2), four nodes for the hidden layer (this is arbitrary but it works well here) and one output node (because we only need one value for the output).  In the first part of this problem you should create a function, for example a function called BackpropXOR, and generates an output value.   In the second part of this problem, described in question 2 (below), you should write a program that trains the network and produces an output which hopefully is close to the expected outputs shown in the table below.





Step 1 

Step 2 

Step 3  

Step 4

Step 5

Step 6

Step 7





2) Write a program that uses the program you created in question 1 to train the network shown above so that when it's trained, it will return as its output the correct value (column 3 of the table above) given specific input values (first two columns of the table).  You can call this program TestBackpropXOR.  This second program does not have to be a function, it can be a regular program (script). 

Step 1 

Step 2 

Step 3  

Step 4

Step 5

Step 6





3) Now, using Matlab functions ("feedforwardnet" and "train") create a network that solves the XOR problem. You can use multiple layers and as many nodes per layer that you'd like since it's very easy to create these using Matlab functions.

Step 1 

Step 2 

Step 3  

Step 4