matthiasm@8: function CPD = maximize_params(CPD, temp) matthiasm@8: % MAXIMIZE_PARAMS Set the params of a CPD to their ML values (dsoftmax) using IRLS matthiasm@8: % CPD = maximize_params(CPD, temperature) matthiasm@8: % temperature parameter is ignored matthiasm@8: matthiasm@8: % Written by Pierpaolo Brutti matthiasm@8: matthiasm@8: if ~adjustable_CPD(CPD), return; end matthiasm@8: options = foptions; matthiasm@8: matthiasm@8: if CPD.verbose matthiasm@8: options(1) = 1; matthiasm@8: else matthiasm@8: options(1) = -1; matthiasm@8: end matthiasm@8: %options(1) = CPD.verbose; matthiasm@8: matthiasm@8: options(2) = CPD.wthresh; matthiasm@8: options(3) = CPD.llthresh; matthiasm@8: options(5) = CPD.approx_hess; matthiasm@8: options(14) = CPD.max_iter; matthiasm@8: matthiasm@8: dpsize = size(CPD.self_vals,3); matthiasm@8: for i=1:dpsize, matthiasm@8: mask=find(CPD.eso_weights(:,:,i)>0); % for adapting the parameters we use only positive weighted example matthiasm@8: if ~isempty(mask), matthiasm@8: if ~isempty(CPD.dps_as_cps.ndx), matthiasm@8: puredp_map = find_equiv_posns(CPD.dpndx, union(CPD.dpndx, CPD.dps_as_cps.ndx)); % find the glm structure matthiasm@8: subs = ind2subv(CPD.sizes(union(CPD.dpndx, CPD.dps_as_cps.ndx)),i); % that corrisponds to the matthiasm@8: active_glm = max([1,subv2ind(CPD.sizes(CPD.dpndx), subs(puredp_map))]); % i-th 'fictitious' example matthiasm@8: matthiasm@8: CPD.glim{active_glm} = netopt_weighted(CPD.glim{active_glm}, options, CPD.parent_vals(mask',:,i),... matthiasm@8: CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), 'scg'); matthiasm@8: else matthiasm@8: alfa = 0.4; if CPD.solo, alfa = 1; end % learning step = 1 <=> self is all alone in the net matthiasm@8: CPD.glim{i} = glmtrain_weighted(CPD.glim{i}, options, CPD.parent_vals(mask',:),... matthiasm@8: CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), alfa); matthiasm@8: end matthiasm@8: end matthiasm@8: mask=[]; matthiasm@8: end