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

76 views (last 30 days)
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 Comments
Junior Barrera
Junior Barrera on 13 Sep 2020
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 on 14 Sep 2020
I don't think this is related to the original question. I think you'd better start a new question.

Sign in to comment.

Accepted Answer

Patel Mounika
Patel Mounika on 22 Feb 2019
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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!