Neural Network Toolbox Previous page   Next Page
sim

Simulate neural network

Syntax

To Get Help

Type help network/sim.

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)

and returns

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:

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 a 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 a Vi x Q matrix.

where

Ni
=
net.numInputs
Nl
=
net.numLayers
No
=
net.numOutputs
D
=
net.numInputDelays
LD
=
net.numLayerDelays
TS
=
Number of time steps
Q
=
Batch size
Ri
=
net.inputs{i}.size
Si
=
net.layers{i}.size
Ui
=
net.outputs{i}.size

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:

P
(sum of Ri) x Q matrix
Pi
(sum of Ri) x (ID*Q) matrix
Ai
(sum of Si) x (LD*Q) matrix
T
(sum of Vi) x Q matrix
Y
(sum of Ui) x Q matrix
Pf
(sum of Ri) x (ID*Q) matrix
Af
(sum of Si) x (LD*Q) matrix
E
(sum of Vi) x Q 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.

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:

See Neuron Model and Network Architectures, for more information on network simulation.

See Also

init, adapt, train, revert


Previous page  setx softmax Next page

© 1984-2006 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments


ptable bgcolor=#e7ebf7 border=0 width=100% cellpadding=0 cellspacing=0tr valign=toptd align=left width=20a href=setx.htmlimg src=b_prev.gif alt=Previous page border=0 align=bottoma tdtd align=left setxtdtd tdtd align=rightsoftmax tdtd align=right width=20a href=softmax.htmlimg src=b_next.gif alt=Next page border=0 align=bottomatdtrtable p class=copy© 1984-2006 The MathWorks, Inc. tt class=minicdot•tt a href=file......license.txtTerms of Usea tt class=minicdot•tt a href=file......patents.txtPatentsa tt class=minicdot•tt a href=file......trademarks.txtTrademarksa tt class=minicdot•tt a href=file....acknowledgments.htmlAcknowledgmentsap br !-- Copyright 2006 The MathWorks, Inc. -- !-- Last updated Mon Dec 18 235648 2006 -- body html