【发布时间】:2014-03-18 14:40:14
【问题描述】:
我正在尝试对神经网络进行多种设计,从这些试验中我想要性能最好的神经网络,然后用性能最好的设计重新训练我的最终网络。我在试验 4 中获得了最佳性能。但是当我尝试使用这些值重新训练网络时,得到不同的输出。请帮我。 我的代码是:
load inputdata
load targetdata
x=input;
t=target;
hiddenLayerSize = 30;
net = patternnet(hiddenLayerSize);
net.trainFcn='trainbr';
net.trainParam.epochs=100;
rng(0);
Ntrials=20;
for i = 1:Ntrials
s{i} = rng;
net = configure(net,x,t);
[ net tr y e] = train(net,x,t);
% Best mseval over all epochs of ith run
netIW0{i} = net.IW
netb0{i} = net.b
netLW0{i} = net.LW
tstind = tr.testInd;
ytst = y(:,tstind);
ttst = t(:,tstind);
%mseval(i) = mse(net,ttst,ytst)
mseval(i)=tr.best_tperf;
plt=plt+1,figure(plt)
plotconfusion(ttst,ytst)
title([ ' TEST SET CONFUSION MATRIX. TRIAL = ', num2str(i)] )
hold off
end
[ minmseval ibest ] = min(mseval);
rng=s{ibest}; % For repeating the best design
bestnet = configure(net,x,t);
[ bestnet tr y e] = train(net,x,t);
bestIW0 = bestnet.IW
bestb0 = bestnet.b
bestLW0 = bestnet.LW
msetst=tr.best_tperf;
tstind = tr.testInd;
ytst = y(:,tstind);
ttst = t(:,tstind);
fWb=getwb(bestnet);
%msetst= mse(bestnet,ttst,ytst)
plt=plt+1,figure(plt)
plotconfusion(ttst,ytst)
title([ ' OVERALL TEST SET CONFUSION MATRIX= '] )
hold off
save bestnet
view(bestnet)
【问题讨论】:
标签: matlab neural-network