annotate _FullBNT/BNT/CPDs/@softmax_CPD/maximize_params.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1 function CPD = maximize_params(CPD, temp)
matthiasm@8 2 % MAXIMIZE_PARAMS Set the params of a CPD to their ML values (dsoftmax) using IRLS
matthiasm@8 3 % CPD = maximize_params(CPD, temperature)
matthiasm@8 4 % temperature parameter is ignored
matthiasm@8 5
matthiasm@8 6 % Written by Pierpaolo Brutti
matthiasm@8 7
matthiasm@8 8 if ~adjustable_CPD(CPD), return; end
matthiasm@8 9 options = foptions;
matthiasm@8 10
matthiasm@8 11 if CPD.verbose
matthiasm@8 12 options(1) = 1;
matthiasm@8 13 else
matthiasm@8 14 options(1) = -1;
matthiasm@8 15 end
matthiasm@8 16 %options(1) = CPD.verbose;
matthiasm@8 17
matthiasm@8 18 options(2) = CPD.wthresh;
matthiasm@8 19 options(3) = CPD.llthresh;
matthiasm@8 20 options(5) = CPD.approx_hess;
matthiasm@8 21 options(14) = CPD.max_iter;
matthiasm@8 22
matthiasm@8 23 dpsize = size(CPD.self_vals,3);
matthiasm@8 24 for i=1:dpsize,
matthiasm@8 25 mask=find(CPD.eso_weights(:,:,i)>0); % for adapting the parameters we use only positive weighted example
matthiasm@8 26 if ~isempty(mask),
matthiasm@8 27 if ~isempty(CPD.dps_as_cps.ndx),
matthiasm@8 28 puredp_map = find_equiv_posns(CPD.dpndx, union(CPD.dpndx, CPD.dps_as_cps.ndx)); % find the glm structure
matthiasm@8 29 subs = ind2subv(CPD.sizes(union(CPD.dpndx, CPD.dps_as_cps.ndx)),i); % that corrisponds to the
matthiasm@8 30 active_glm = max([1,subv2ind(CPD.sizes(CPD.dpndx), subs(puredp_map))]); % i-th 'fictitious' example
matthiasm@8 31
matthiasm@8 32 CPD.glim{active_glm} = netopt_weighted(CPD.glim{active_glm}, options, CPD.parent_vals(mask',:,i),...
matthiasm@8 33 CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), 'scg');
matthiasm@8 34 else
matthiasm@8 35 alfa = 0.4; if CPD.solo, alfa = 1; end % learning step = 1 <=> self is all alone in the net
matthiasm@8 36 CPD.glim{i} = glmtrain_weighted(CPD.glim{i}, options, CPD.parent_vals(mask',:),...
matthiasm@8 37 CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), alfa);
matthiasm@8 38 end
matthiasm@8 39 end
matthiasm@8 40 mask=[];
matthiasm@8 41 end