Neural network (NN)
11 views (last 30 days)
Show older comments
Kerrollenna Martta
on 6 Oct 2022
Commented: Walter Roberson
on 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 Comments
Accepted Answer
Walter Roberson
on 6 Oct 2022
Edited: Walter Roberson
on 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 Comments
Walter Roberson
on 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.
More Answers (0)
See Also
Categories
Find more on Define Shallow Neural Network Architectures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!