annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@softmax_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 Set the params of a CPD to their ML values (dsoftmax) using IRLS
wolffd@0 3 % CPD = maximize_params(CPD, temperature)
wolffd@0 4 % temperature parameter is ignored
wolffd@0 5
wolffd@0 6 % Written by Pierpaolo Brutti
wolffd@0 7
wolffd@0 8 if ~adjustable_CPD(CPD), return; end
wolffd@0 9 options = foptions;
wolffd@0 10
wolffd@0 11 if CPD.verbose
wolffd@0 12 options(1) = 1;
wolffd@0 13 else
wolffd@0 14 options(1) = -1;
wolffd@0 15 end
wolffd@0 16 %options(1) = CPD.verbose;
wolffd@0 17
wolffd@0 18 options(2) = CPD.wthresh;
wolffd@0 19 options(3) = CPD.llthresh;
wolffd@0 20 options(5) = CPD.approx_hess;
wolffd@0 21 options(14) = CPD.max_iter;
wolffd@0 22
wolffd@0 23 dpsize = size(CPD.self_vals,3);
wolffd@0 24 for i=1:dpsize,
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 if ~isempty(CPD.dps_as_cps.ndx),
wolffd@0 28 puredp_map = find_equiv_posns(CPD.dpndx, union(CPD.dpndx, CPD.dps_as_cps.ndx)); % find the glm structure
wolffd@0 29 subs = ind2subv(CPD.sizes(union(CPD.dpndx, CPD.dps_as_cps.ndx)),i); % that corrisponds to the
wolffd@0 30 active_glm = max([1,subv2ind(CPD.sizes(CPD.dpndx), subs(puredp_map))]); % i-th 'fictitious' example
wolffd@0 31
wolffd@0 32 CPD.glim{active_glm} = netopt_weighted(CPD.glim{active_glm}, options, CPD.parent_vals(mask',:,i),...
wolffd@0 33 CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), 'scg');
wolffd@0 34 else
wolffd@0 35 alfa = 0.4; if CPD.solo, alfa = 1; end % learning step = 1 <=> self is all alone in the net
wolffd@0 36 CPD.glim{i} = glmtrain_weighted(CPD.glim{i}, options, CPD.parent_vals(mask',:),...
wolffd@0 37 CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), alfa);
wolffd@0 38 end
wolffd@0 39 end
wolffd@0 40 mask=[];
wolffd@0 41 end