Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/bnt/examples/static/Brutti/Belief_hme.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 % Sigmoid Belief Hierarchical Mixtures of Experts |
wolffd@0 | 2 |
wolffd@0 | 3 clear all |
wolffd@0 | 4 clc |
wolffd@0 | 5 X = 1; |
wolffd@0 | 6 Q1 = 2; |
wolffd@0 | 7 Q2 = 3; |
wolffd@0 | 8 Y = 4; |
wolffd@0 | 9 dag = zeros(4,4); |
wolffd@0 | 10 dag(X,[Q1 Q2 Y]) = 1; |
wolffd@0 | 11 dag(Q1, [Q2 Y]) = 1; |
wolffd@0 | 12 dag(Q2,Y)=1; |
wolffd@0 | 13 ns = [1 3 4 3]; |
wolffd@0 | 14 dnodes = [2 3 4]; |
wolffd@0 | 15 onodes=[1 2 3 4]; |
wolffd@0 | 16 bnet = mk_bnet(dag,ns, dnodes); |
wolffd@0 | 17 |
wolffd@0 | 18 rand('state',0); randn('state',0); |
wolffd@0 | 19 |
wolffd@0 | 20 bnet.CPD{1} = root_CPD(bnet, 1); |
wolffd@0 | 21 bnet.CPD{2} = softmax_CPD(bnet, 2, 'max_iter', 3); |
wolffd@0 | 22 bnet.CPD{3} = softmax_CPD(bnet, 3, 'discrete', [2], 'max_iter', 3); |
wolffd@0 | 23 bnet.CPD{4} = softmax_CPD(bnet, 4, 'discrete', [2 3], 'max_iter', 3); |
wolffd@0 | 24 |
wolffd@0 | 25 T=5; |
wolffd@0 | 26 cases = cell(4, T); |
wolffd@0 | 27 cases(1,:)=num2cell(rand(1,T)); |
wolffd@0 | 28 %cases(2,:)=num2cell(round(rand(1,T)*2)+1); |
wolffd@0 | 29 %cases(3,:)=num2cell(round(rand(1,T)*3)+1); |
wolffd@0 | 30 cases(4,:)=num2cell(round(rand(1,T)*2)+1); |
wolffd@0 | 31 |
wolffd@0 | 32 engine = jtree_inf_engine(bnet, onodes); |
wolffd@0 | 33 |
wolffd@0 | 34 [engine, loglik] = enter_evidence(engine, cases); |
wolffd@0 | 35 |
wolffd@0 | 36 disp('learning-------------------------------------------') |
wolffd@0 | 37 [bnet2, LL2] = learn_params_em(engine, cases, 4); |