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

70 ビュー (過去 30 日間)
Robert Roos
Robert Roos 2019 年 2 月 19 日
移動済み: KSSV 2022 年 10 月 17 日
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 件のコメント
Roberto Williams Cedeño
Roberto Williams Cedeño 2021 年 5 月 14 日
Thanks Patel.
CARLOS MAURICIO RUIZ DIAZ
CARLOS MAURICIO RUIZ DIAZ 2022 年 2 月 20 日
Thanks mi friend, I had the same question!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSequence 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