annotate toolboxes/FullBNT-1.0.7/bnt/examples/static/HME/hme_topobuilder.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [bnet, onodes]=hme_topobuilder(nodes_info);
wolffd@0 2 %
wolffd@0 3 % HME topology builder
wolffd@0 4 %
wolffd@0 5 % ----------------------------------------------------------------------------------------------------
wolffd@0 6 % -> pierpaolo_b@hotmail.com or -> pampo@interfree.it
wolffd@0 7 % ----------------------------------------------------------------------------------------------------
wolffd@0 8
wolffd@0 9 nodes_num=size(nodes_info,2);
wolffd@0 10 dag = zeros(nodes_num);
wolffd@0 11 list=[1:nodes_num];
wolffd@0 12 for i=1:(nodes_num-1)
wolffd@0 13 app=[];
wolffd@0 14 app=list((i+1):end);
wolffd@0 15 dag(i,app) = 1;
wolffd@0 16 end
wolffd@0 17 onodes = [1 nodes_num];
wolffd@0 18 dnodes = list(2:end-1);
wolffd@0 19 if nodes_info(1,end)>0,
wolffd@0 20 dnodes=[dnodes nodes_num];
wolffd@0 21 end
wolffd@0 22 ns = nodes_info(2,:);
wolffd@0 23
wolffd@0 24 bnet = mk_bnet(dag, ns, dnodes);
wolffd@0 25 clamped = 0;
wolffd@0 26
wolffd@0 27 bnet.CPD{1} = root_CPD(bnet, 1);
wolffd@0 28
wolffd@0 29 rand('state', 50);
wolffd@0 30 randn('state', 50);
wolffd@0 31
wolffd@0 32 for i=2:nodes_num,
wolffd@0 33 if (nodes_info(1,i)==0)&(nodes_info(4,i)==1),
wolffd@0 34 bnet.CPD{i} = gaussian_CPD(bnet, i, [], [], [], 'full');
wolffd@0 35 elseif (nodes_info(1,i)==0)&(nodes_info(4,i)==2),
wolffd@0 36 bnet.CPD{i} = gaussian_CPD(bnet, i, [], [], [], 'diag');
wolffd@0 37 elseif (nodes_info(1,i)==0)&(nodes_info(4,i)==3),
wolffd@0 38 bnet.CPD{i} = gaussian_CPD(bnet, i, [], [], [], 'full', 'tied');
wolffd@0 39 elseif (nodes_info(1,i)==0)&(nodes_info(4,i)==4),
wolffd@0 40 bnet.CPD{i} = gaussian_CPD(bnet, i, [], [], [], 'diag', 'tied');
wolffd@0 41 elseif nodes_info(1,i)==1,
wolffd@0 42 %bnet.CPD{i} = dsoftmax_CPD(bnet, i, [], [], clamped, nodes_info(4,i));
wolffd@0 43 bnet.CPD{i} = softmax_CPD(bnet, i, 'clamped', clamped, 'max_iter', nodes_info(4,i));
wolffd@0 44 else
wolffd@0 45 bnet.CPD{i} = mlp_CPD(bnet, i, nodes_info(3,i), [], [], [], [], clamped, nodes_info(4,i));
wolffd@0 46 end
wolffd@0 47 end