Neural network (NN)
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kerrollenna Martta
le 6 Oct 2022
Commenté : Walter Roberson
le 22 Oct 2022
Hi. I have problem to train my Neural Network. This is the coding.
clear
clc
load c.mat
load OUTPUT1.mat
inputrain = c(1:1000,:);
targetrain = OUTPUT1(1:1000);
[pn,mininputrain,maxinputrain,tn,mintargetrain,maxtargetrain] = premnmx(inputrain,targetrain);
net=newff(minmax(pn),[20,10,1],{'logsig','logsig','purelin'},'trainlm');
net=init(net);
net.trainParam.show = 1;
net.trainParam.lr = 0.9;
net.trainParam.mc = 0.9;
net.trainParam.epochs = 1000;
net.trainParam.goal = 1e-3;
net = train(net,pn,tn);
an = sim(net,pn);
[a] = postmnmx(an,mintargetrain,maxtargetrain);
result_norm = [an' tn'];
result_denorm = [a' targetrain'];
error = mse(tn-an);
mape = mean(abs(error./tn));
rmse = sqrt(mean((error - tn).^2));
[m,b,r] = postreg(a,targetrain);
save net.mat net
The error said " Output data size does not match net.outputs{3}.size." Help me please. Thank you
2 commentaires
Réponse acceptée
Walter Roberson
le 6 Oct 2022
Modifié(e) : Walter Roberson
le 6 Oct 2022
net=newff(minmax(pn),[20,10,1],{'logsig','logsig','purelin'},'trainlm');
You are missing a parameter. The {'logsig'} and so on vector must be the 4th parameter. The first three parameters must be P, T, S where P is input vectors, T is target vectors, and S is sizes of the input layers. S can be [] if you want it to be calculated based upon the sizes of the entries in T.
2 commentaires
Walter Roberson
le 22 Oct 2022
premnmx was obsoleted in R2006a, so it is difficult to find documentation for it.
I suspect that maybe you should use
net=newff(pn, tn, [20,10,1], {'logsig','logsig','purelin'}, 'trainlm');
but newff() was obsoleted in R2010b . You should probably modernize the code.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Define Shallow Neural Network Architectures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!