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:
Prashant Kumar answered .
2025-11-20
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation. % Create a Fitting Network hiddenLayer1Size = 10; hiddenLayer2Size = 10; net = fitnet([hiddenLayer1Size hiddenLayer2Size], trainFcn);