| Neural Network Toolbox | ![]() |
Create a custom neural network
Syntax
net = network(numInputs,numLayers,biasConnect,inputConnect, layerConnect,outputConnect,targetConnect)
To Get Help
Description
network creates new custom networks. It is used to create networks that are then customized by functions such as newp, newlin, newff, etc.
network takes these optional arguments (shown with default values):
numInputs - Number of inputs, 0.
numLayers - Number of layers, 0.
biasConnect - numLayers-by-1 Boolean vector, zeros.
inputConnect - numLayers-by-numInputs Boolean matrix, zeros.
layerConnect - numLayers-by-numLayers Boolean matrix, zeros.
outputConnect - 1-by-numLayers Boolean vector, zeros.
targetConnect - 1-by-numLayers Boolean vector, zeros.
net - New network with the given property values.
Properties
net.numInputs: 0 or a positive integer.
net.numLayers: 0 or a positive integer.
net.biasConnect: numLayer-by-1 Boolean vector.
If net.biasConnect(i) is 1, then the layer i has a bias and net.biases{i} is a structure describing that bias.
net.inputConnect: numLayer-by-numInputs Boolean vector.
If net.inputConnect(i,j) is 1, then layer i has a weight coming from input j and net.inputWeights{i,j} is a structure describing that weight.
net.layerConnect: numLayer-by-numLayers Boolean vector.
If net.layerConnect(i,j) is 1, then layer i has a weight coming from layer j and net.layerWeights{i,j} is a structure describing that weight.
net.outputConnect: 1-by-numLayers Boolean vector.
If net.outputConnect(i) is 1, then the network has an output from layer i and net.outputs{i} is a structure describing that output.
net.targetConnect: 1-by-numLayers Boolean vector.
If net.outputConnect(i) is 1, then the network has a target from layer i and net.targets{i} is a structure describing that target.
net.numOutputs: 0 or a positive integer. Read only.
net.numTargets: 0 or a positive integer. Read only.
net.numInputDelays: 0 or a positive integer. Read only.
net.numLayerDelays: 0 or a positive number. Read only.
Subobject structure properties:
net.inputs: numInputs-by-1 cell array.
net.layers: numLayers-by-1 cell array.
net.biases: numLayers-by-1 cell array.
net.inputWeights: numLayers-by-numInputs cell array.
If net.inputConnect(i,j) is 1, then net.inputWeights{i,j} is a structure defining the weight to layer i from input j.
net.layerWeights: numLayers-by-numLayers cell array.
If net.layerConnect(i,j) is 1, then net.layerWeights{i,j} is a structure defining the weight to layer i from layer j.
net.outputs: 1-by-numLayers cell array.
If net.outputConnect(i) is 1, then net.outputs{i} is a structure defining the network output from layer i.
net.targets: 1-by-numLayers cell array.
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 ''.
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: numLayers-by-numInputs cell array of input weight values.
net.LW: numLayers-by-numLayers cell array of layer weight values.
net.b: numLayers-by-1 cell array of bias values.
net.userdata: structure you can use to store useful values.
Examples
Here is the code to create a network without any inputs and layers, and then set its number of inputs and layer to 1 and 2 respectively.
Here is the code to create the same network with one line of code.
Here is the code to create a 1 input, 2 layer, feed-forward network. Only the first layer will have a bias. An input weight will connect to layer 1 from input 1. A layer weight will connect to layer 2 from layer 1. Layer 2 will be a network output, and have a target.
We can then see the properties of subobjects as follows:
net.inputs{1} net.layers{1}, net.layers{2} net.biases{1} net.inputWeights{1,1}, net.layerWeights{2,1} net.outputs{2} net.targets{2}
We can get the weight matrices and bias vector as follows:
We can alter the properties of any of these subobjects. Here we change the transfer functions of both layers:
Here we change the number of elements in input 1 to 2, by setting each element's range:
Next we can simulate the network for a two-element input vector:
See Also
| netsum | newc | ![]() |