This page was automatically generated by NetLogo 4.0. Questions, problems? Contact email@example.com.
The applet requires Java 1.4.1 or higher. It will not run on
Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use
a browser that supports Java 1.4. (Safari works, IE does not.
Mac OS X comes with Safari. Open Safari and set it as your default
web browser under Safari/Preferences/General.)
On other operating systems, you may obtain the latest Java plugin from
Sun’s Java site. General information on the models, including instructions for running them on your own computer, is available from the NetLogo Simulation Information Page. To download this page, do not use "Save As," but right-click (or on Macs control-click) on this link. You also need to download the NetLogo program, which you can do by right-clicking or control-clicking this link.
created with NetLogo
view/download model file: Artificial-Neural-Net.nlogo
This is a model of a very small neural network. It is based on the Perceptron model, but instead of one layer, this network has two layers of "perceptrons". That means it can learn operations a single layer cannot.
The goal of a network is to take input from its input nodes on the far left and classify those inputs appropriately in the output nodes on the far right. It does this by being given a lot of examples and attempting to classify them, and having a supervisor tell it if the classification was right or wrong. Based on this information the neural network updates its weight until it correctly classifies all inputs correctly.
Initially the weights on the links of the networks are random. When inputs are fed into the network on the far left, those inputs times the random weights are added up to create the activation for the next node in the network. The next node then sends out an activation along its output link. These link weights and activations are summed up by the final output node which reports a value. This activation is passed through a sigmoid function, which means that values near 0 are assigned values close to 0, and vice versa for 1. The values increase nonlinearly between 0 and 1 with a sharp transition at 0.5.
To train the network a lot of inputs are presented to the network along with how the network should correctly classify the inputs. The network uses a back-propagation algorithm to pass error back from the output node and uses this error to update the weights along each link.
To use it press SETUP to create the network and initialize the weights to small random numbers.
Press TRAIN ONCE to run one epoch of training. The number of examples presented to the network during this epoch is controlled by EXAMPLES-PER-EPOCH slider.
Press TRAIN to continually train the network.
In the view, the larger the size of the link the greater the weight it has. If the link is red then its a positive weight. If the link is blue then its a negative weight.
To test the network, set INPUT-1 and INPUT-2, then press the TEST button. A dialog box will appear telling you whether or not the network was able to correctly classify the input that you gave it.
LEARNING-RATE controls how much the neural network will learn from any one example.
TARGET-FUNCTION allows you to choose which function the network is trying to solve.
Unlike the Perceptron model, this model is able to learn both OR and XOR. It is able to learn XOR because the hidden layer (the middle nodes) in a way allows the network to draw two lines classifying the input into positive and negative regions. As a result one of the nodes will learn essentially the OR function that if either of the inputs is on it should be on, and the other node will learn an exclusion function that if both of the inputs or on it should be on (but weighted negatively).
However unlike the perceptron model, the neural network model takes longer to learn any of the functions, including the simple OR function. This is because it has a lot more that it needs to learn. The perceptron model had to learn three different weights (the input links, and the bias link). The neural network model has to learn ten weights (4 input to hidden layer weights, 2 hidden layer to output weight and the three bias weights).
Manipulate the LEARNING-RATE parameter. Can you speed up or slow down the training?
Switch back and forth between OR and XOR several times during a run. Why does it take less time for the network to return to 0 error the longer the network runs?
Add additional functions for the network to learn beside OR and XOR. This may require you to add additional hidden nodes to the network.
Back-propagation using gradient descent is considered somewhat unrealistic as a model of real neurons, because in the real neuronal system there is no way for the output node to pass its error back. Can you implement another weight-update rule that is more valid?
This model uses the link primitives. It also makes heavy use of lists.
This is the second in the series of models devoted to understanding artificial neural networks. The first model is Perceptron.
The code for this model is inspired by the pseudo-code which can be found in Tom M. Mitchell's "Machine Learning" (1997).
Thanks to Craig Brozefsky for his work in improving this model.
To refer to this model in academic publications, please use: Rand, W. and Wilensky, U. (2006). NetLogo Artificial Neural Net model. http://ccl.northwestern.edu/netlogo/models/ArtificialNeuralNet. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.