Neural Network with learngdm as adaptation learning function

조회 수: 4 (최근 30일)
Diego Mauricio Beramendi Ortega
Diego Mauricio Beramendi Ortega 2022년 7월 12일
답변: aditi bagora 2023년 10월 19일
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.

답변 (1개)

aditi bagora
aditi bagora 2023년 10월 19일
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

카테고리

Help CenterFile Exchange에서 Sequence 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