Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/examples/static/Brutti/Belief_hmdt.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 Hidden Markov Decision Tree (Jordan/Gharhamani 1996) | |
2 % | |
3 clear all; | |
4 %clc; | |
5 rand('state',0); randn('state',0); | |
6 X = 1; Q1 = 2; Q2 = 3; Y = 4; | |
7 % intra time-slice graph | |
8 intra=zeros(4); | |
9 intra(X,[Q1 Q2 Y])=1; | |
10 intra(Q1,[Q2 Y])=1; | |
11 intra(Q2, Y)=1; | |
12 % inter time-slice graph | |
13 inter=zeros(4); | |
14 inter(Q1,Q1)=1; | |
15 inter(Q2,Q2)=1; | |
16 | |
17 ns = [1 2 3 1]; | |
18 dnodes = [2 3]; | |
19 eclass1 = [1 2 3 4]; | |
20 eclass2 = [1 5 6 4]; | |
21 bnet = mk_dbn(intra, inter, ns, dnodes, eclass1, eclass2); | |
22 | |
23 bnet.CPD{1} = root_CPD(bnet, 1); | |
24 % ========================================= | |
25 bnet.CPD{2} = softmax_CPD(bnet, 2); | |
26 bnet.CPD{3} = softmax_CPD(bnet, 3, 'discrete', [2]); | |
27 bnet.CPD{5} = softmax_CPD(bnet, 6); | |
28 bnet.CPD{6} = softmax_CPD(bnet, 7, 'discrete', [3 6]); | |
29 % ========================================= | |
30 bnet.CPD{4} = gaussian_CPD(bnet, 4); | |
31 | |
32 % make some data | |
33 T=20; | |
34 cases = cell(4, T); | |
35 cases(1,:)=num2cell(round(rand(1,T)*2)+1); | |
36 %cases(2,:)=num2cell(round(rand(1,T))+1); | |
37 %cases(3,:)=num2cell(round(rand(1,T)*2)+1); | |
38 cases(4,:)=num2cell(rand(1,T)); | |
39 | |
40 engine = bk_inf_engine(bnet, 'exact', [1 2 3 4]); | |
41 | |
42 % log lik before learning | |
43 [engine, loglik] = enter_evidence(engine, cases); | |
44 | |
45 % do learning | |
46 ev=cell(1,1); | |
47 ev{1}=cases; | |
48 [bnet2, LL2] = learn_params_dbn_em(engine, ev, 10); |