pso_neteval.m

来自「微粒群工具箱PSOt为PSO的工具箱」· M 代码 · 共 32 行

M
32
字号
% pso_neteval.m
% function to evaluate a neural nets performance as called from
% the PSO function: pso_Trelea_vectorized.m and trainpso.m
%
%  usage: cost = pso_neteval(x)
%   where x is an MxN array of weights & biases
%       M is particle index
%       N is weight & bias index

% Brian Birge
% Rev 2.0
% 3/8/06

function cost = pso_neteval(x)
  for i=1:length(x(:,1)) % # of particles passed, because of simfuncname we can't vectorize
    net = evalin('caller','net');

    Pd = evalin('caller','Pd');
    Tl = evalin('caller','Tl');
    Ai = evalin('caller','Ai');
    Q  = evalin('caller','Q');
    TS = evalin('caller','TS');
    
    X   = x(i,:)';    
    net = setx(net,X); % setx is mega-slow

    [perf,El,Ac,N,Zb,Zi,Zl] = calcperf(net,X,Pd,Tl,Ai,Q,TS);

    cost(i,1) = perf;
  end
  
return

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?