Matlab Ntrials后的神经网络再训练

Matlab Ntrials后的神经网络再训练,matlab,neural-network,Matlab,Neural Network,我正在尝试对神经网络进行多种设计,从这些试验中,我想要性能最好的神经网络,然后用性能最好的设计对我的最终网络进行再培训。我在试用4中获得了最好的表现。但是当我尝试用这些值重新训练网络时,我得到了不同的输出。请帮帮我。 我的代码是: load inputdata load targetdata x=input; t=target; hiddenLayerSize = 30; net = patternnet(hiddenLayerSize); net.trainFcn='trainbr'; n

我正在尝试对神经网络进行多种设计,从这些试验中,我想要性能最好的神经网络,然后用性能最好的设计对我的最终网络进行再培训。我在试用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)

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