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

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:

ANSWER provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

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.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.