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