load input
load output
p=input';
t=output';
[ I N } = size(p) % [ 1 3988 ]
[ O N } = size(t) % [ 1 3988 ]
Neq = N*O % No. of training equations
H = 10 % trial No. of hidden nodes for I-H-O node topology
Nw =(I+1)*H+(H+1)*O % 31 = No. of unknown weights to estimate from Neq =3998 eqs.
Ndof = Neq-Nw % No. of estimation DOF (degrees of freedom, (see Wikipedia))
% Since Neq/Nw ~ 128 >> 10, do not need validation data.
Ntrn = N
Ntrneq = Neq
MSEtrn00 = mean(var(t',1)) % Biased Reference MSEtrn
MSEtrn00a = mean(var(t',0)) % Unbiased Reference: DOF "a"djusted
% Choose one depending on your version of NNTBX:
%net = newff(minmax(p),[ H O ]); % VERY OBSOLETE
%net = newfit(p, t, H); % OBSOLETE
net = fitnet(H); net = configure(net,p,t); % CURRENT
MSEgoal = 0.01*Ndof*MSEtrn00a/Ntrneq % R2agoal = 0.99
net.trainParam.goal= MSEgoal;
net.trainParam.min_grad = MSEtrn00/200;
net.divideFcn = '';
[ net tr Y E ] = train(net,p,t);
stopcrit = tr.stop
bestepoch = tr.best_epoch
MSEtrn = tr.perf(bestepoch)
MSEtrna = Ntrneq*MSEtrn/Ndof
NMSEtrn = MSEtrn/MSEtrn00
NMSEtrna = MSEtrna/MSEtrn00a
R2 = 1 -NMSE % ( R^2 = coefficient of determination ... See Wikipedia)
R2a = 1 - NMSEa % ( DOFA R^2)
If you are not satisfied with the R2a estimate of the fraction of target variance that is modeled, change H.
Hope this helps.
Thank you for formally accepting my answer
Greg
P.S. It is worthwhile to study the results of the following commands (no semocolon)
net = net
tr = tr
Best Answer