network
Create custom shallow neural network
Syntax
net = network
net = network(numInputs,numLayers,biasConnect,inputConnect,layerConnect,outputConnect)
To Get Help
Type help network/network
.
Tip
To learn how to create a deep learning network, see dlnetwork
.
Description
network
creates new custom networks. It is used to create networks that
are then customized by functions such as feedforwardnet
and
narxnet
.
net = network
without arguments returns a new neural network with no
inputs, layers or outputs.
net = network(numInputs,numLayers,biasConnect,inputConnect,layerConnect,outputConnect)
takes these optional arguments (shown with default values):
numInputs | Number of inputs, 0 |
numLayers | Number of layers, 0 |
biasConnect |
|
inputConnect |
|
layerConnect |
|
outputConnect | 1-by- |
and returns
net | New network with the given property values |
Properties
Architecture Properties
net.numInputs | 0 or a positive integer | Number of inputs. |
net.numLayers | 0 or a positive integer | Number of layers. |
net.biasConnect |
| If |
net.inputConnect |
| If |
net.layerConnect |
| If |
net.outputConnect | 1-by- | If |
net.numOutputs | 0 or a positive integer (read only) | Number of network outputs according to
|
net.numInputDelays | 0 or a positive integer (read only) | Maximum input delay according to all
|
net.numLayerDelays | 0 or a positive number (read only) | Maximum layer delay according to all
|
Subobject Structure Properties
net.inputs |
|
|
net.layers |
|
|
net.biases |
| If |
net.inputWeights |
| If |
net.layerWeights |
| If |
net.outputs | 1-by- | If |
Function Properties
net.adaptFcn | Name of a network adaption function or |
net.initFcn | Name of a network initialization function or
|
net.performFcn | Name of a network performance function or |
net.trainFcn | Name of a network training function or |
Parameter Properties
net.adaptParam | Network adaption parameters |
net.initParam | Network initialization parameters |
net.performParam | Network performance parameters |
net.trainParam | Network training parameters |
Weight and Bias Value Properties
net.IW |
|
net.LW |
|
net.b |
|
Other Properties
net.userdata | Structure you can use to store useful values |
Examples
Create Network with One Input and Two Layers
This example shows how to create a network without any inputs and layers, and then set its numbers of inputs and layers to 1 and 2 respectively.
net = network net.numInputs = 1 net.numLayers = 2
Alternatively, you can create the same network with one line of code.
net = network(1,2)
Create Feedforward Network and View Properties
This example shows how to create a one-input, two-layer, feedforward network. Only the first layer has a bias. An input weight connects to layer 1 from input 1. A layer weight connects to layer 2 from layer 1. Layer 2 is a network output and has a target.
net = network(1,2,[1;0],[1; 0],[0 0; 1 0],[0 1])
You can view the network subobjects with the following code.
net.inputs{1} net.layers{1}, net.layers{2} net.biases{1} net.inputWeights{1,1}, net.layerWeights{2,1} net.outputs{2}
You can alter the properties of any of the network subobjects. This code changes the transfer functions of both layers:
net.layers{1}.transferFcn = 'tansig'; net.layers{2}.transferFcn = 'logsig';
You can view the weights for the connection from the first input to the first layer as
follows. The weights for a connection from an input to a layer are stored in
net.IW
. If the values are not yet set, these result is empty.
net.IW{1,1}
You can view the weights for the connection from the first layer to the second layer as
follows. Weights for a connection from a layer to a layer are stored in
net.LW
. Again, if the values are not yet set, the result is empty.
net.LW{2,1}
You can view the bias values for the first layer as follows.
net.b{1}
To change the number of elements in input 1 to 2, set each element’s range:
net.inputs{1}.range = [0 1; -1 1];
After training your network, you can use sim
to simulate the network.
For example, simulate the network for a two-element input vector.
p = [0.5; -0.1]; y = sim(net,p)
Version History
Introduced before R2006a