Neural Network with learngdm as adaptation learning function

4 Ansichten (letzte 30 Tage)
Diego Mauricio Beramendi Ortega
Beantwortet: aditi bagora am 19 Okt. 2023
Hi all,
I need to apply a ANN to solve a regression problem. The network must have three inputs and one output. The network type is Feed-forward back propagation, the training function is trainlm, the adaptation learning function is learngdm, the performance function is MSE and the network could have one hidden layer. So far, I applied nntool to solve this problem but I later I have to use a for loop to built the network many times with different ANN parameters (e.g. number of hidden layers). Could anyone give me a small example of matlab code to construct a ANN with the mentioned characteristics? I am having problems to implement learndgm as learning function. A portion of the data I am using is attached to this post.
Thanks in advance.

Antworten (1)

aditi bagora
aditi bagora am 19 Okt. 2023
Hello Diego,
I understand that you are trying to build an ANN with hidden layer of varying sizes and following parameters.
  • Training function: trainlm
  • Learning function: learngdm
  • Performance function: MSE
I am attaching a sample code that creates an ANN with the given parameters. You can use the “createnetwork()” function to define network with varying hidden layer sizes.
net = createnetwork([10,8]); % create a network
% number_hidden_layers is a vector of number of neurons required in each layer [10,8] means a network with 2 layers of sizes 10 and 8 respectively.
function net = createnetwork(number_hidden_layers)
net = feedforwardnet(number_hidden_layers); % Specify the number of hidden layers and neurons per layer
% Set the training function, adaptation learning function, and performance function
net.trainFcn = 'trainlm';
net.adaptFcn = 'learngdm';
net.performFcn = 'mse';
% Divide the data into training, validation, and testing sets
net.divideFcn = 'dividerand';
net.divideMode = 'sample';
net.divideParam.trainRatio = 0.7;
net.divideParam.valRatio = 0.15;
net.divideParam.testRatio = 0.15;
end
Hope this helps!
Regards,
Aditi

Kategorien

Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by