Create Custom Neural Network - MATLAB Network
Create Custom Neural Network - MATLAB Network
network
Create custom 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 Specify Layers of Convolutional Neural Network.
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.
and returns
Properties
Architecture Properties
net.numInputs 0 or a positive integer Number of inputs.
http://www.mathworks.com/help/deeplearning/ref/network.html;jsessionid=0e8ce9952d7915d2fe746ae2fa54 1/4
10/29/2018 Create custom neural network - MATLAB network
Function Properties
net.adaptFcn Name of a network adaption function or ''
Parameter Properties
net.adaptParam Network adaption parameters
http://www.mathworks.com/help/deeplearning/ref/network.html;jsessionid=0e8ce9952d7915d2fe746ae2fa54 2/4
10/29/2018 Create custom neural network - MATLAB network
Other Properties
net.userdata Structure you can use to store useful values
Examples
net = network
net.numInputs = 1
net.numLayers = 2
Alternatively, you can create the same network with one line of code.
net = network(1,2)
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.
http://www.mathworks.com/help/deeplearning/ref/network.html;jsessionid=0e8ce9952d7915d2fe746ae2fa54 3/4
10/29/2018 Create custom neural network - MATLAB network
net.b{1}
net.inputs{1}.range = [0 1; -1 1];
To simulate the network for a two-element input vector, the code might look like this:
p = [0.5; -0.1];
y = sim(net,p)
See Also
sim
Topics
Neural Network Object Properties
Neural Network Subobject Properties
http://www.mathworks.com/help/deeplearning/ref/network.html;jsessionid=0e8ce9952d7915d2fe746ae2fa54 4/4