Neural Network Toolbox |
Syntax
[Y,Pf,Af,E,perf] = sim(net,P,Pi,Ai,T) [Y,Pf,Af,E,perf] = sim(net,{Q TS},Pi,Ai,T) [Y,Pf,Af,E,perf] = sim(net,Q,Pi,Ai,T)
To Get Help
Description
sim
simulates neural networks.
[Y,Pf,Af,E,perf]
= sim(net,P,Pi,Ai,T)
takes
net |
Network |
P |
Network inputs |
Pi |
Initial input delay conditions (default = zeros) |
Ai |
Initial layer delay conditions (default = zeros) |
T |
Network targets (default = zeros) |
Y |
Network outputs |
Pf |
Final input delay conditions |
Af |
Final layer delay conditions |
E |
Network errors |
perf |
Network performance |
Note that arguments Pi
, Ai
, Pf
, and Af
are optional and need only be used for networks that have input or layer delays.
sim
's signal arguments can have two formats: cell array or matrix.
The cell array format is easiest to describe. It is most convenient for networks with multiple inputs and outputs, and allows sequences of inputs to be presented:
The columns of Pi
, Ai
, Pf
, and Af
are ordered from oldest delay condition to most recent:
Pi{i,k} |
= |
|
Input i at time ts = k - ID |
Pf{i,k} |
= |
|
Input i at time ts = TS + k - ID |
Ai{i,k} |
= |
|
Layer output i at time ts = k - LD |
Af{i,k} |
= |
|
Layer output i at time ts = TS + k - LD |
The matrix format can be used if only one time step is to be simulated (TS = 1)
. It is convenient for networks with only one input and output, but can also be used with networks that have more.
Each matrix argument is found by storing the elements of the corresponding cell array argument in a single matrix:
[Y,Pf,Af] = sim(net,{Q TS},Pi,Ai)
is used for networks that do not have an input, such as Hopfield networks, when cell array notation is used.
Examples
Here newp
is used to create a perceptron layer with a two-element input (with ranges of [0 1]
) and a single neuron.
Here the perceptron is simulated for an individual vector, a batch of three vectors, and a sequence of three vectors.
p1 = [.2; .9]; a1 = sim(net,p1) p2 = [.2 .5 .1; .9 .3 .7]; a2 = sim(net,p2) p3 = {[.2; .9] [.5; .3] [.1; .7]}; a3 = sim(net,p3)
Here newlind
is used to create a linear layer with a three-element input and two neurons.
The linear layer is simulated with a sequence of two input vectors using the default initial input delay conditions (all zeros).
The layer is simulated for three more vectors, using the previous final input delay conditions as the new initial delay conditions.
Here newelm
is used to create an Elman network with a one-element input, and a layer 1 with three tansig
neurons followed by a layer 2 with two purelin
neurons. Because it is an Elman network, it has a tapped delay line with a delay of 1 going from layer 1 to layer 1.
The Elman network is simulated for a sequence of three values, using default initial delay conditions.
The network is simulated for four more values, using the previous final delay conditions as the new initial delay conditions.
Algorithm
sim
uses these properties to simulate a network net
.
These properties determine the network's weight and bias values and the number of delays associated with each weight:
These function properties indicate how sim
applies weight and bias values to inputs to get each layer's output:
net.inputWeights{i,j}.weightFcn net.layerWeights{i,j}.weightFcn net.layers{i}.netInputFcn net.layers{i}.transferFcn
See Neuron Model and Network Architectures, for more information on network simulation.
See Also
setx | softmax |
© 1984-2006 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments