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

Train neural network

Syntax

To Get Help

Type help network/train.

Description

train trains a network net according to net.trainFcn and net.trainParam.

train(net,P,T,Pi,Ai) takes

net
Network
P
Network inputs
T
Network targets (default = zeros)
Pi
Initial input delay conditions (default = zeros)
Ai
Initial layer delay conditions (default = zeros)

and returns

net
New network
tr
Training record (epoch and perf)
Y
Network outputs
E
Network errors
Pf
Final input delay conditions
Af
Final layer delay conditions

Note that T is optional and need only be used for networks that require targets. Pi and Pf are also optional and need only be used for networks that have input or layer delays. Optional arguments VV and TV are described below.

train'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,j,ts} is an Ni x Q matrix.
T
Nl x TS cell array
Each element T{i,ts} is a Ui 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.
Y
No x TS cell array
Each element Y{i,ts} is a Ui x Q matrix.
E
No x TS cell array
Each element E{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.

where

Ni
=

net.numInputs
Nl
=

net.numLayers
ID
=

net.numInputDelays
LD
=

net.numLayerDelays
TS
=

Number of time steps
Q
=

Batch size
Ri
=

net.inputs{i}.size
Si
=

net.layers{i}.size

The columns of Pi, Pf, Ai, and Af are ordered from the oldest delay condition to the most recent:

Pi{i,k}
=

Input i at time ts = k - ID
Pf{i,k}
=

Input i at time ts = TS + k - D
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 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
T
(sum of Ui) x Q matrix
Pi
(sum of Ri) x (ID*Q) matrix
Ai
(sum of Si) x (LD*Q) matrix
Y
(sum of Ui) x Q matrix
E
(sum of Ui) x Q matrix
Pf
(sum of Ri) x (ID*Q) matrix
Af
(sum of Si) x (LD*Q) matrix

Examples

Here input P and targets T define a simple function that you can plot:

Here newff is used to create a two-layer feed-forward network. The network has one hidden layer with ten neurons.

The network is trained for up to 50 epochs to an error goal of 0.01 and then resimulated.

Algorithm

train calls the function indicated by net.trainFcn, using the training parameter values indicated by net.trainParam.

Typically one epoch of training is defined as a single presentation of all input vectors to the network. The network is then updated according to the results of all those presentations.

Training occurs until a maximum number of epochs occurs, the performance goal is met, or any other stopping condition of the function net.trainFcn occurs.

Some training functions depart from this norm by presenting only one input vector (or sequence) each epoch. An input vector (or sequence) is chosen randomly each epoch from concurrent input vectors (or sequences). newc and newsom return networks that use trainr, a training function that does this.

See Also

init, revert, sim, adapt


 Provide feedback about this page 

Previous page tansig trainb Next page

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