Neural Network Object Properties
These properties define the basic features of a network. Neural Network Subobject Properties describes properties that define network details.
General
Here are the general properties of neural networks.
net.name
This property consists of a string defining the network name. Network creation
functions, such as feedforwardnet
, define this appropriately.
But it can be set to any string as desired.
net.userdata
This property provides a place for users to add custom information to a network object. Only one field is predefined. It contains a secret message to all Deep Learning Toolbox™ users:
net.userdata.note
Architecture
These properties determine the number of network subobjects (which include inputs, layers, outputs, targets, biases, and weights), and how they are connected.
net.numInputs
This property defines the number of inputs a network receives. It can be set to 0 or a positive integer.
Clarification. The number of network inputs and the size of a network input are
not the same thing. The number of inputs defines how many sets of
vectors the network receives as input. The size of each input (i.e., the number of
elements in each input vector) is determined by the input size
(net.inputs{i}.size
).
Most networks have only one input, whose size is determined by the problem.
Side Effects. Any change to this property results in a change in the size of the matrix defining
connections to layers from inputs, (net.inputConnect
) and the size of
the cell array of input subobjects (net.inputs
).
net.numLayers
This property defines the number of layers a network has. It can be set to 0 or a positive integer.
Side Effects. Any change to this property changes the size of each of these Boolean matrices that define connections to and from layers:
net.biasConnect net.inputConnect net.layerConnect net.outputConnect
and changes the size of each cell array of subobject structures whose size depends on the number of layers:
net.biases net.inputWeights net.layerWeights net.outputs
and also changes the size of each of the network's adjustable parameter's properties:
net.IW net.LW net.b
net.biasConnect
This property defines which layers have biases. It can be set to any
N-by-1 matrix of Boolean values, where
Nl is the number of network layers
(net.numLayers
). The presence (or absence) of a bias to the
ith layer is indicated by a 1 (or 0) at
net.biasConnect(i)
Side Effects. Any change to this property alters the presence or absence of structures in the cell
array of biases (net.biases
) and, in the presence or absence of
vectors in the cell array, of bias vectors (net.b
).
net.inputConnect
This property defines which layers have weights coming from inputs.
It can be set to any Nl ×
Ni matrix of Boolean values, where
Nl is the number of network layers
(net.numLayers
), and Ni is
the number of network inputs (net.numInputs
). The presence (or absence)
of a weight going to the ith layer from the jth
input is indicated by a 1 (or 0) at net.inputConnect(i,j)
.
Side Effects. Any change to this property alters the presence or absence of structures in the cell
array of input weight subobjects (net.inputWeights
) and the presence
or absence of matrices in the cell array of input weight matrices
(net.IW
).
net.layerConnect
This property defines which layers have weights coming from other layers. It can be
set to any Nl ×
Nl matrix of Boolean values, where
Nl is the number of network layers
(net.numLayers
). The presence (or absence) of a weight going to the
ith layer from the jth layer is indicated by a 1
(or 0) at
net.layerConnect(i,j)
Side Effects. Any change to this property alters the presence or absence of structures in the cell
array of layer weight subobjects (net.layerWeights
) and the presence
or absence of matrices in the cell array of layer weight matrices
(net.LW
).
net.outputConnect
This property defines which layers generate network outputs. It can be set to any 1
× Nl matrix of Boolean values, where
Nl is the number of network layers
(net.numLayers
). The presence (or absence) of a network output from
the ith layer is indicated by a 1 (or 0) at
net.outputConnect(i)
.
Side Effects. Any change to this property alters the number of network outputs
(net.numOutputs
) and the presence or absence of structures in the
cell array of output subobjects (net.outputs
).
net.numOutputs (read only)
This property indicates how many outputs the network has. It is always equal to the
number of 1s in net.outputConnect
.
net.numInputDelays (read only)
This property indicates the number of time steps of past inputs that must be supplied to simulate the network. It is always set to the maximum delay value associated with any of the network's input weights:
numInputDelays = 0; for i=1:net.numLayers for j=1:net.numInputs if net.inputConnect(i,j) numInputDelays = max( ... [numInputDelays net.inputWeights{i,j}.delays]); end end end
net.numLayerDelays (read only)
This property indicates the number of time steps of past layer outputs that must be supplied to simulate the network. It is always set to the maximum delay value associated with any of the network's layer weights:
numLayerDelays = 0; for i=1:net.numLayers for j=1:net.numLayers if net.layerConnect(i,j) numLayerDelays = max( ... [numLayerDelays net.layerWeights{i,j}.delays]); end end end
net.numWeightElements (read only)
This property indicates the number of weight and bias values in the network. It is the sum of the number of elements in the matrices stored in the two cell arrays:
net.IW new.b
Subobject Structures
These properties consist of cell arrays of structures that define each of the network's inputs, layers, outputs, targets, biases, and weights.
The properties for each kind of subobject are described in Neural Network Subobject Properties.
net.inputs
This property holds structures of properties for each of the network's inputs. It is
always an Ni × 1 cell array of input
structures, where Ni is the number of network
inputs (net.numInputs
).
The structure defining the properties of the ith network input is located at
net.inputs{i}
If a neural network has only one input, then you can access
net.inputs{1}
without the cell array notation as follows:
net.input
Input Properties. See Inputs for descriptions of input properties.
net.layers
This property holds structures of properties for each of the network's layers. It is
always an Nl × 1 cell array of layer
structures, where Nl is the number of network
layers (net.numLayers
).
The structure defining the properties of the ith layer is located
at net.layers{i}
.
Layer Properties. See Layers for descriptions of layer properties.
net.outputs
This property holds structures of properties for each of the network's outputs. It is
always a 1 × Nl cell array, where
Nl is the number of network outputs
(net.numOutputs
).
The structure defining the properties of the output from the ith
layer (or a null matrix []
) is located at
net.outputs{i}
if net.outputConnect(i)
is 1 (or
0).
If a neural network has only one output at layer i
, then you can
access net.outputs{i}
without the cell array notation as
follows:
net.output
Output Properties. See Outputs for descriptions of output properties.
net.biases
This property holds structures of properties for each of the network's biases. It is
always an Nl × 1 cell array, where
Nl is the number of network layers
(net.numLayers
).
The structure defining the properties of the bias associated with the
ith layer (or a null matrix []
) is located at
net.biases{i}
if net.biasConnect(i)
is 1 (or
0).
Bias Properties. See Biases for descriptions of bias properties.
net.inputWeights
This property holds structures of properties for each of the network's input weights.
It is always an Nl ×
Ni cell array, where
Nl is the number of network layers
(net.numLayers
), and Ni is
the number of network inputs (net.numInputs
).
The structure defining the properties of the weight going to the
ith layer from the jth input (or a null matrix
[]
) is located at net.inputWeights{i,j}
if
net.inputConnect(i,j)
is 1 (or 0).
Input Weight Properties. See Input Weights for descriptions of input weight properties.
net.layerWeights
This property holds structures of properties for each of the network's layer weights.
It is always an Nl
×Nl cell array, where
Nl is the number of network layers
(net.numLayers
).
The structure defining the properties of the weight going to the
ith layer from the jth layer (or a null matrix
[]
) is located at net.layerWeights{i,j}
if
net.layerConnect(i,j)
is 1 (or 0).
Layer Weight Properties. See Layer Weights for descriptions of layer weight properties.
Functions
These properties define the algorithms to use when a network is to adapt, is to be initialized, is to have its performance measured, or is to be trained.
net.adaptFcn
This property defines the function to be used when the network adapts. It can be set
to the name of any network adapt function. The network adapt function is used to perform
adaption whenever adapt
is called.
[net,Y,E,Pf,Af] = adapt(NET,P,T,Pi,Ai)
For a list of functions, type help nntrain
.
Side Effects. Whenever this property is altered, the network's adaption parameters
(net.adaptParam
) are set to contain the parameters and default
values of the new function.
net.adaptParam
This property defines the parameters and values of the current adapt function. Call
help
on the current adapt function to get a description of what each
field means:
help(net.adaptFcn)
net.derivFcn
This property defines the derivative function to be used to calculate error gradients and Jacobians when the network is trained using a supervised algorithm, such as backpropagation. You can set this property to the name of any derivative function.
For a list of functions, type help nnderivative
.
net.divideFcn
This property defines the data division function to be used when the network is trained using a supervised algorithm, such as backpropagation. You can set this property to the name of a division function.
For a list of functions, type help nndivision
.
Side Effects. Whenever this property is altered, the network's adaption parameters
(net.divideParam
) are set to contain the parameters and default
values of the new function.
net.divideParam
This property defines the parameters and values of the current data-division function. To get a description of what each field means, type the following command:
help(net.divideFcn)
net.divideMode
This property defines the target data dimensions which to divide up when the data
division function is called. Its default value is 'sample'
for static
networks and 'time'
for dynamic networks. It may also be set to
'sampletime'
to divide targets by both sample and timestep,
'all'
to divide up targets by every scalar value, or
'none'
to not divide up data at all (in which case all data is used
for training, none for validation or testing).
net.initFcn
This property defines the function used to initialize the network's weight matrices
and bias vectors.
The
initialization function is used to initialize the network whenever init
is called:
net = init(net)
Side Effects. Whenever this property is altered, the network's initialization parameters
(net.initParam
) are set to contain the parameters and default
values of the new function.
net.initParam
This property defines the parameters and values of the current initialization
function. Call help
on the current initialization function to get a
description of what each field means:
help(net.initFcn)
net.performFcn
This property defines the function used to measure the
network’s performance. The performance function is used to calculate network performance
during training whenever train
is called.
[net,tr] = train(NET,P,T,Pi,Ai)
For a list of functions, type help nnperformance
.
Side Effects. Whenever this property is altered, the network's performance parameters
(net.performParam
) are set to contain the parameters and default
values of the new function.
net.performParam
This property defines the parameters and values of the current performance function.
Call help
on the current performance function to get a description of
what each field means:
help(net.performFcn)
net.plotFcns
This property consists of a row cell array of strings, defining the plot functions
associated with a network. The neural network training window, which is opened by the
train
function, shows a button for each
plotting function. Click the button during or after training to open the desired
plot.
net.plotParams
This property consists of a row cell array of structures, defining the parameters and
values of each plot function in net.plotFcns
. Call
help
on the each plot function to get a description of what each
field means:
help(net.plotFcns{i})
net.trainFcn
This property defines the function used to train the network. It can be set to the
name of any of the training functions, which is used to train the network whenever
train
is called.
[net,tr] = train(NET,P,T,Pi,Ai)
For a list of functions, type help nntrain
.
Side Effects. Whenever this property is altered, the network's training parameters
(net.trainParam
) are set to contain the parameters and default
values of the new function.
net.trainParam
This property defines the parameters and values of the current training function. Call
help
on the current training function to get a description of what
each field means:
help(net.trainFcn)
Weight and Bias Values
These properties define the network's adjustable parameters: its weight matrices and bias vectors.
net.IW
This property defines the weight matrices of weights going to layers from network
inputs. It is always an Nl ×
Ni cell array, where
Nl is the number of network layers
(net.numLayers
), and Ni is
the number of network inputs (net.numInputs
).
The weight matrix for the weight going to the ith layer from the
jth input (or a null matrix []
) is located at
net.IW{i,j}
if net.inputConnect(i,j)
is
1
(or 0
).
The weight matrix has as many rows as the size of the layer it goes to
(net.layers{i}.size
). It has as many columns as the product of the
input size with the number of delays associated with the weight:
net.inputs{j}.size * length(net.inputWeights{i,j}.delays)
The preprocessing function net.inputs{i}.processFcns
is specified
as 'removeconstantrows'
by default in some networks. In this case, if
the network input X
contains m
rows where all row
elements have the same value, the weight matrix has m
less columns than
the above product. For more details about the network input X
, see
train
.
These dimensions can also be obtained from the input weight properties:
net.inputWeights{i,j}.size
net.LW
This property defines the weight matrices of weights going to layers from other
layers. It is always an Nl ×
Nl cell array, where
Nl is the number of network layers
(net.numLayers
).
The weight matrix for the weight going to the ith layer from the
jth layer (or a null matrix []
) is located at
net.LW{i,j}
if net.layerConnect(i,j)
is 1 (or
0).
The weight matrix has as many rows as the size of the layer it goes to
(net.layers{i}.size
). It has as many columns as the product of the
size of the layer it comes from with the number of delays associated with the
weight:
net.layers{j}.size * length(net.layerWeights{i,j}.delays)
These dimensions can also be obtained from the layer weight properties:
net.layerWeights{i,j}.size
net.b
This property defines the bias vectors for each layer with a bias. It is always an
Nl × 1 cell array, where
Nl is the number of network layers
(net.numLayers
).
The bias vector for the ith layer (or a null matrix
[]
) is located at net.b{i}
if
net.biasConnect(i)
is 1 (or 0).
The number of elements in the bias vector is always equal to the size of the layer it
is associated with (net.layers{i}.size
).
This dimension can also be obtained from the bias properties:
net.biases{i}.size
See Also
feedforwardnet
| patternnet
| network