11-05-2013, 03:49 PM
Neural Network Toolbox™ 6 User’s Guide
]Neural Network.pdf (Size: 5.73 MB / Downloads: 69)
Introduction
This chapter has a number of objectives. First, it introduces you to learning
rules, methods of deriving the next changes that might be made in a network,
and training, a procedure whereby a network is actually adjusted to do a
particular job. Along the way, this chapter describes a toolbox function to
create a simple perceptron network and functions to initialize and simulate
such networks. The perceptron is used as a vehicle for tying these concepts
together.
Rosenblatt [Rose61] created many variations of the perceptron. One of the
simplest was a single-layer network whose weights and biases could be trained
to produce a correct target vector when presented with the corresponding input
vector. The training technique used is called the perceptron learning rule. The
perceptron generated great interest due to its ability to generalize from its
training vectors and learn from initially randomly distributed connections.
Perceptrons are especially suited for simple problems in pattern classification.
They are fast and reliable networks for the problems they can solve. In
addition, an understanding of the operations of the perceptron provides a good
basis for understanding more complex networks.
Important Perceptron Functions
You can create perceptron networks with the function newp. These networks
can be initialized, simulated, and trained with init, sim, and train. “Neuron
Model” on page 3-3 describes how perceptrons work and introduces these
functions.
Perceptron Architecture
The perceptron network consists of a single layer of S perceptron neurons
connected to R inputs through a set of weights wi,j, as shown below in two
forms. As before, the network indices i and j indicate that wi,j is the strength of
the connection from the jth input to the ith neuron.
Simulation (sim)
This section shows how sim works using a simple problem.
Suppose that you take a perceptron with a single two-element input vector,
such as discussed in the decision boundary figure on page 3-4. This perceptron
outputs the values 0 and 1.
Learning Rules
A learning rule is defined as a procedure for modifying the weights and biases
of a network. (This procedure can also be referred to as a training algorithm.)
The learning rule is applied to train the network to perform some particular
task. Learning rules in this toolbox fall into two broad categories: supervised
learning, and unsupervised learning.
Training (train)
If sim and learnp are used repeatedly to present inputs to a perceptron, and to
change the perceptron weights and biases according to the error, the
perceptron will eventually find weight and bias values that solve the problem,
given that the perceptron can solve it. Each traversal through all the training
input and target vectors is called a pass.
The function train carries out such a loop of calculation. In each pass the
function train proceeds through the specified sequence of inputs, calculating
the output, error, and network adjustment for each input vector in the
sequence as the inputs are presented.
Limitations and Cautions
Perceptron networks should be trained with adapt, which presents the input
vectors to the network one at a time and makes corrections to the network
based on the results of each presentation. Use of adapt in this way guarantees
that any linearly separable problem is solved in a finite number of training
presentations.
As noted in the previous pages, perceptrons can also be trained with the
function train, which is discussed in detail in the next chapter. Commonly
when train is used for perceptrons, it presents the inputs to the network in
batches, and makes corrections to the network based on the sum of all the
individual corrections. Unfortunately, there is no proof that such a training
algorithm converges for perceptrons. On that account the use of train for
perceptrons is not recommended.
Graphical User Interface
Introduction to the GUI
The graphical user interface (GUI) is designed to be simple and user friendly.
A simple example will get you started.
You bring up a GUI Network/Data Manager window. This window has its own
work area, separate from the more familiar command-line workspace. Thus,
when using the GUI, you might export the GUI results to the (command-line)
workspace. Similarly, you might want to import results from the workspace to
the GUI.
Once the Network/Data Manager window is up and running, you can create a
network, view it, train it, simulate it, and export the final results to the
workspace. Similarly, you can import data from the workspace for use in the
GUI.
Create Network
Now create a new network and call it ANDNet. Select the Network tab. Enter
ANDNet under Name. Set the Network Type to Perceptron, for that is the kind
of network you want to create.
You can set the inputs to p, and the example targets to t.
You can use a hardlim transfer function with the output range [0, 1] that
matches the target values and a learnp learning function. For the Transfer
function, select hardlim. For the Learning function, select learnp. The
Create Network or Data window now looks like the following figure.
Train the Perceptron
To train the network, click ANDNet to highlight it. Then click Open. This leads
to a new window, labeled Network: ANDNet. At this point you can see the
network again by clicking the View tab. You can also check on the initialization
by clicking the Initialize tab. Now click the Train tab. Specify the inputs and
output by clicking the Training Info tab and selecting p from the list of inputs
and t from the list of targets.
Export Perceptron Results to Workspace
To export the network outputs and errors to the MATLAB® workspace, go back
to the Network/Data Manager window. The output and error for ANDNet are
listed in the Outputs and Errors fields on the right side. Next click Export.
This gives you an Export from Network/Data Manager window. Click
ANDNet_outputs and ANDNet_errors to highlight them, and then click the
Export button.
Save a Variable to a File and Load It Later
Bring up the Network/Data Manager window and click New Network. Set the
name to mynet. Click Create. The network name mynet should appear in the
Network/Data Manager window. In this same window click Export. Select
mynet in the variable list of the Export or Save window and click Save. This
leads to the Save to a MAT File window. Save to the file mynetfile.
Now get rid of mynet in the GUI and retrieve it from the saved file. Go to the
Network/ Data Manager window, highlight mynet, and click Delete. Click
Import. This brings up the Import or Load to Network/Data Manager window.
Click the Load from Disk button and type mynetfile as the MAT-file Name.
Now click Browse. This brings up the Select MAT File window, with
mynetfile as an option that you can select as a variable to be imported.
Highlight mynetfile, click Open, and you return to the Import or Load to
Network/Data Manager window. On the Import As list, select Network.
Highlight mynet and click Load to bring mynet to the GUI. Now mynet is back
in the GUI Network/Data Manager window.