Effacer les filtres
Effacer les filtres

Neural Network with learngdm as adaptation learning function

7 vues (au cours des 30 derniers jours)
Diego Mauricio Beramendi Ortega
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.

Réponses (1)

aditi bagora
aditi bagora le 19 Oct 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

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by