How to create a fitnet neural network with multiple hidden layers?

70 次查看(过去 30 天)
I am new to using the machine learning toolboxes of MATLAB (but loving it so far!)
From a large data set I want to fit a neural network, to approximate the underlying unknown function. I have used the "Neural Net Fitting" app and generated a script with it which builds and trains my network. It all works, however the results are not good enough. I think the network is not complex enough to cover the non-linearities. So, I figued I'd add another hidden layer, but I can't get it to work.
The current code to produce the network is the following (which is the default):
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize, trainFcn);
How would I modify this to add more hidden layers?
I am looking to get the classical Multi-Layer Perceptron (MLP) network, with potentially even more hidden layers:
  2 个评论
Junior Barrera
Junior Barrera 2020-9-13
Dear friends,
I would like to design a network, that I will call net_R similar to this one, but with the following charactersitics:
Design a basic module with four neurons:
w1x1 + w2x2 + k1<= 0
w1x1 + w2x2 + k2 > =0
-(1/w1)x1 + w2x2 + k3 <= 0
-(1/w1)x1 + w2x2 + k4 >=0
that is, net_R(x1,x2) = 1 <=> (x1,x2) is insided the rectangle nearned from a sample. Not that this 4 perceptrons network depends just of four parameters: (w1,w2,k1,k2,k3,k4). This should imply in less data due to the sharp
modeling that imply in smaller VC-dimension.
ii-design the netowork Net-4 that integrates 4 net_R(x1,x2) by the OR connective, that is,
Net-4(x1,x2) = 1 <=> net_R(y)(x1,x2)=1 for y=1,2,3 or 4,
y being the indides of the rectangle networks.
Thank you very much
Junior Barrera (Univrsity of SP - Brazil)
Robert Roos
Robert Roos 2020-9-14
I don't think this is related to the original question. I think you'd better start a new question.

请先登录,再进行评论。

采纳的回答

Patel Mounika
Patel Mounika 2019-2-22
You can add more hidden layers as shown below:
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayer1Size = 10;
hiddenLayer2Size = 10;
net = fitnet([hiddenLayer1Size hiddenLayer2Size], trainFcn);
This creates network of 2 hidden layers of size 10 each.
Hope this helps.
  5 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by