Neural Network Toolbox™ Previous page   Next Page 
newp
 Provide feedback about this page

Create perceptron

Syntax

Description

Perceptrons are used to solve simple (i.e., linearly separable) classification problems.

net = newp(PR,S,TF,LF) takes these inputs,

PR
R x 2 matrix of min and max values for R input elements
S
Number of neurons
TF
Transfer function (default = 'hardlim')
LF
Learning function (default = 'learnp')

and returns a new perceptron.

The transfer function TF can be hardlim or hardlims. The learning function LF can be learnp or learnpn.

Properties

Perceptrons consist of a single layer with the dotprod weight function, the netsum net input function, and the specified transfer function.

The layer has a weight from the input and a bias.

Weights and biases are initialized with initzero.

Adaption and training are done with trains and trainc, which both update weight and bias values with the specified learning function. Performance is measured with mae.

Examples

This code creates a perceptron layer with one two-element input (ranges [0 1] and [-2 2]) and one neuron. (Supplying only two arguments to newp results in the default perceptron learning function learnp's being used.)

Here you simulate the network's response to a sequence of inputs P.

Define a sequence of targets T (together P and T define the operation of an AND gate), and then let the network adapt for 10 passes through the sequence. Then simulate the updated network.

Now define a new problem, an OR gate, with batch inputs P and targets T.

Here you initialize the perceptron (resulting in new random weight and bias values), simulate its output, train for a maximum of 20 epochs, and then simulate it again.

Notes

Perceptrons can classify linearly separable classes in a finite amount of time. If input vectors have large variances in their lengths, learnpn can be faster than learnp.

See Also

sim, init, adapt, train, hardlim, hardlims, learnp, learnpn, trains, trainc


 Provide feedback about this page 

Previous page newnarxsp newpnn Next page

 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS