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,PiAi,T)
takes,
Pi
-- Initial input delay conditions, default = zeros
Note that arguments Pi
, Ai
, Pf
, and Af
are optional and need only be used for networks that have input or layer delays.
's signal arguments can have two formats: cell array or matrix.
sim
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:
P
-- Ni
x TS
cell array, each element P{i,ts}
is an Ri
x Q
matrix
Pi
-- Ni
x ID
cell array, each element Pi{i,k}
is an Ri
x Q
matrix
Ai
-- Nl
x LD
cell array, each element Ai{i,k}
is an Si
x Q
matrix
T
-- Nt
x TS
cell array, each element P{i,ts
} is an Vi
x Q
matrix
Y
-- NO
x TS
cell array, each element Y{i,ts}
is a Ui
x Q
matrix
Pf
-- Ni
x ID
cell array, each element Pf{i,k}
is an Ri
x Q
matrix
Af
-- Nl
x LD
cell array, each element Af{i,k}
is an Si
x Q
matrix
E
-- Nt
x TS
cell array, each element P{i,ts}
is an Vi
x Q
matrix
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
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 into a single matrix:
Pi
-- (sum of Ri)
x (ID*Q)
matrix
Ai
-- (sum of Si)
x (LD*Q)
matrix
Pf
-- (sum of Ri)
x (ID*Q)
matrix
[Y,Pf,Af] = sim(net,{Q TS},Pi,Ai)
is used for networks which 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, two neurons.
Here the linear layer is simulated with a sequence of two input vectors using the default initial input delay conditions (all zeros).
Here 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 tap delay line with a delay of 1 going from layer 1 to layer 1.
Here the Elman network is simulated for a sequence of three values using default initial delay conditions.
Here 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 |
© 1994-2005 The MathWorks, Inc.