Mercurial > hg > camir-ismir2012
annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@mlp_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 Find ML params of an MLP using Scaled Conjugated Gradient (SCG) |
Daniel@0 | 3 % CPD = maximize_params(CPD, temperature) |
Daniel@0 | 4 % temperature parameter is ignored |
Daniel@0 | 5 |
Daniel@0 | 6 if ~adjustable_CPD(CPD), return; end |
Daniel@0 | 7 options = foptions; |
Daniel@0 | 8 |
Daniel@0 | 9 % options(1) >= 0 means print an annoying message when the max. num. iter. is reached |
Daniel@0 | 10 if CPD.verbose |
Daniel@0 | 11 options(1) = 1; |
Daniel@0 | 12 else |
Daniel@0 | 13 options(1) = -1; |
Daniel@0 | 14 end |
Daniel@0 | 15 %options(1) = CPD.verbose; |
Daniel@0 | 16 |
Daniel@0 | 17 options(2) = CPD.wthresh; |
Daniel@0 | 18 options(3) = CPD.llthresh; |
Daniel@0 | 19 options(14) = CPD.max_iter; |
Daniel@0 | 20 |
Daniel@0 | 21 dpsz=length(CPD.mlp); |
Daniel@0 | 22 |
Daniel@0 | 23 for i=1:dpsz |
Daniel@0 | 24 mask=[]; |
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 CPD.mlp{i} = netopt_weighted(CPD.mlp{i}, options, CPD.parent_vals(mask',:), CPD.self_vals(mask',:,i), CPD.eso_weights(mask',:,i), 'scg'); |
Daniel@0 | 28 |
Daniel@0 | 29 CPD.W1(:,:,i)=CPD.mlp{i}.w1; % update the parameters matrix |
Daniel@0 | 30 CPD.b1(i,:)=CPD.mlp{i}.b1; % |
Daniel@0 | 31 CPD.W2(:,:,i)=CPD.mlp{i}.w2; % update the parameters matrix |
Daniel@0 | 32 CPD.b2(i,:)=CPD.mlp{i}.b2; % |
Daniel@0 | 33 end |
Daniel@0 | 34 end |