【问题标题】:Retrain neural network after NtrialsNtrials 后重新训练神经网络
【发布时间】: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


    【解决方案1】:

    我不知道为什么你不能重现你最好的网络。但是您可以通过将这 20 个网络中的每一个都保存为单独的对象来解决这个问题,而不是只调用最好的一个并删除其他的。这将是一种更快的方法,因为您不需要再次训练您的网络。

    【讨论】:

      猜你喜欢
      • 2014-04-20
      • 2011-04-07
      • 1970-01-01
      • 2016-02-25
      • 1970-01-01
      • 2010-11-20
      • 2019-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多