annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@mlp_CPD/maximize_params.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function CPD = maximize_params(CPD, temp)
wolffd@0 2 % MAXIMIZE_PARAMS Find ML params of an MLP using Scaled Conjugated Gradient (SCG)
wolffd@0 3 % CPD = maximize_params(CPD, temperature)
wolffd@0 4 % temperature parameter is ignored
wolffd@0 5
wolffd@0 6 if ~adjustable_CPD(CPD), return; end
wolffd@0 7 options = foptions;
wolffd@0 8
wolffd@0 9 % options(1) >= 0 means print an annoying message when the max. num. iter. is reached
wolffd@0 10 if CPD.verbose
wolffd@0 11 options(1) = 1;
wolffd@0 12 else
wolffd@0 13 options(1) = -1;
wolffd@0 14 end
wolffd@0 15 %options(1) = CPD.verbose;
wolffd@0 16
wolffd@0 17 options(2) = CPD.wthresh;
wolffd@0 18 options(3) = CPD.llthresh;
wolffd@0 19 options(14) = CPD.max_iter;
wolffd@0 20
wolffd@0 21 dpsz=length(CPD.mlp);
wolffd@0 22
wolffd@0 23 for i=1:dpsz
wolffd@0 24 mask=[];
wolffd@0 25 mask=find(CPD.eso_weights(:,:,i)>0); % for adapting the parameters we use only positive weighted example
wolffd@0 26 if ~isempty(mask),
wolffd@0 27 CPD.mlp{i} = netopt_weighted(CPD.mlp{i}, options, CPD.parent_vals(mask',:), CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), 'scg');
wolffd@0 28
wolffd@0 29 CPD.W1(:,:,i)=CPD.mlp{i}.w1; % update the parameters matrix
wolffd@0 30 CPD.b1(i,:)=CPD.mlp{i}.b1; %
wolffd@0 31 CPD.W2(:,:,i)=CPD.mlp{i}.w2; % update the parameters matrix
wolffd@0 32 CPD.b2(i,:)=CPD.mlp{i}.b2; %
wolffd@0 33 end
wolffd@0 34 end