Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/docs/dbn_hmm_demo.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 Example due to Wang Hee Lin" <engp1622@nus.edu.sg | |
2 | |
3 | |
4 intra = zeros(2); | |
5 intra(1,2) = 1; | |
6 inter = zeros(2); | |
7 inter(1,1) = 1; | |
8 | |
9 Q = 2; % num hidden states | |
10 O = 2; % num observable symbols | |
11 ns = [Q O];%number of states | |
12 dnodes = 1:2; | |
13 %onodes = [1:2]; % only possible with jtree, not hmm | |
14 onodes = [2]; | |
15 bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'observed', onodes); | |
16 for i=1:4 | |
17 bnet.CPD{i} = tabular_CPD(bnet, i); | |
18 end | |
19 | |
20 prior0 = normalise(rand(Q,1)); | |
21 transmat0 = mk_stochastic(rand(Q,Q)); | |
22 obsmat0 = mk_stochastic(rand(Q,O)); | |
23 | |
24 %engine = smoother_engine(hmm_2TBN_inf_engine(bnet)); | |
25 engine = smoother_engine(jtree_2TBN_inf_engine(bnet)); | |
26 | |
27 ss = 2;%slice size(ss) | |
28 ncases = 10;%number of examples | |
29 T=10; | |
30 max_iter=2;%iterations for EM | |
31 cases = cell(1, ncases); | |
32 for i=1:ncases | |
33 ev = sample_dbn(bnet, T); | |
34 cases{i} = cell(ss,T); | |
35 cases{i}(onodes,:) = ev(onodes, :); | |
36 end | |
37 [bnet2, LLtrace] = learn_params_dbn_em(engine, cases, 'max_iter', 4); |