annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@softmax_CPD/maximize_params.m @ 0:cc4b1211e677 tip

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