Prepared By: Y. Michael Jiang, City College of New York, Feb. 4, 2001, Comments/Questions are welcome, please email: michael212@onebox.com.
We have all agreed that XOR problem could NOT solved using Perceptron Method, and it requires one hidden layer & one output layer, since it’s NOT linearly separable. Please note that Input Signal does NOT counted as a layer, in Matlab implementation.
Step 1: Design Phrase:
figure 1
![]() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
figure 4
Similarly, type in “T” (without double quote) on Name, and corresponding matrix =[0 1 1 0] as value, select Targets, under DataType, if it’s not on, then confirm by click on Create.
Now, it comes the fun part, let’s create a XORNet, by click on New Network, you should see a screen like following, please change all the parameters on the screen to the values as indicated on the following screen:
Performance Function = MSE
Numbers of Layer = 2
Here is one of the tricky parts:
Select Layer 1, type in “2” (without quote) for the number of neurons, & select TANSIG as Transfer Function.
Select Layer 2, type in “1” (without quote) for the number of neurons, & select TANSIG as Transfer Function.
Then, please confirm by hitting Create button, which concludes the XOR network implementation phrase.
Step 2: Network Training:
Now, highlight XORNet with ONE click, then click on Train button, a screen will appear just like following:
figure 6
On Training Info, please select P as Inputs, T as Targets.
On Training Parameters, please specify:
1000 for epochs, since we’d like to have longer duration for the train.
0.000000000000001 for goal, since we would like to see if the XORNet we just implemented is capable to produce high precise result.
50 for max_fail.
After, confirming all the parameters have been specified as indented, please hit on Train Network for live action of the training and performance plot, you should get a decaying plot similar to the following plot, but may NOT be exact shape, due to the randomness of the calculation:
figure 7
Now, the XORNet has been trained successfully and ready for simulation if needed.
Step 3: Network simulation:
With trained network, simulation is a way of testing on the network to see if it meets our expectation.
Now, create a new testing data S (with
a matrix [1; 0] representing a set of two inputs) on the NN Network Manager,
follow the same procedure just like what you did with Input P, on Step
1.
HighLight XORNet again with one click,
then click on Simulate button on the Network Manager. Select
S as Inputs, type in “XORNet_outputsSim” (without quote) as Outputs,
then hit Simulate Network button and check the result of XORNet_outputSim
on the NN Network Manager, by click View.
This concludes the whole process of XOR network design, training & simulation.
We hope this demo has been helpful to
each one of you, by introducing the nntool. Enjoy your journey on the road
of computing. For more reference, please visit www.mathworks.com
& www.mathtools.net.