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