maximize_params.m

来自「基于matlab的bayes net toolbox,希望对大家能有些帮助」· M 代码 · 共 35 行

M
35
字号
function CPD = maximize_params(CPD, temp)
% MAXIMIZE_PARAMS Find ML params of an MLP using Scaled Conjugated Gradient (SCG)
% CPD = maximize_params(CPD, temperature)
% temperature parameter is ignored

if ~adjustable_CPD(CPD), return; end
options = foptions;

% options(1) >= 0 means print an annoying message when the max. num. iter. is reached
if CPD.verbose
  options(1) = 1;
else
  options(1) = -1;
end
%options(1) = CPD.verbose;

options(2) = CPD.wthresh;
options(3) = CPD.llthresh;
options(14) = CPD.max_iter;

dpsz=length(CPD.mlp);

for i=1:dpsz
    mask=[];
    mask=find(CPD.eso_weights(:,:,i)>0);    % for adapting the parameters we use only positive weighted example
    if  ~isempty(mask),
        CPD.mlp{i} = netopt_weighted(CPD.mlp{i}, options, CPD.parent_vals(mask',:), CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), 'scg');
        
        CPD.W1(:,:,i)=CPD.mlp{i}.w1;        % update the parameters matrix
        CPD.b1(i,:)=CPD.mlp{i}.b1;          %
        CPD.W2(:,:,i)=CPD.mlp{i}.w2;        % update the parameters matrix
        CPD.b2(i,:)=CPD.mlp{i}.b2;          %
    end
end

⌨️ 快捷键说明

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