wolffd@0
|
1 % Compare the speeds of various inference engines on a coupled HMM
|
wolffd@0
|
2
|
wolffd@0
|
3 N = 3;
|
wolffd@0
|
4 Q = 2;
|
wolffd@0
|
5 rand('state', 0);
|
wolffd@0
|
6 randn('state', 0);
|
wolffd@0
|
7 discrete = 0;
|
wolffd@0
|
8 if discrete
|
wolffd@0
|
9 Y = 2; % size of output alphabet
|
wolffd@0
|
10 else
|
wolffd@0
|
11 Y = 3; % size of observed vectors
|
wolffd@0
|
12 end
|
wolffd@0
|
13 coupled = 1;
|
wolffd@0
|
14 bnet = mk_chmm(N, Q, Y, discrete, coupled);
|
wolffd@0
|
15 %bnet = mk_fhmm(N, Q, Y, discrete); % factorial HMM
|
wolffd@0
|
16 ss = length(bnet.node_sizes_slice);
|
wolffd@0
|
17
|
wolffd@0
|
18 T = 3;
|
wolffd@0
|
19
|
wolffd@0
|
20 USEC = exist('@jtree_C_inf_engine/collect_evidence','file');
|
wolffd@0
|
21
|
wolffd@0
|
22 engine = {};
|
wolffd@0
|
23 engine{end+1} = jtree_dbn_inf_engine(bnet);
|
wolffd@0
|
24 %engine{end+1} = jtree_ndx_dbn_inf_engine(bnet, 'ndx_type', 'SD');
|
wolffd@0
|
25 %engine{end+1} = jtree_ndx_dbn_inf_engine(bnet, 'ndx_type', 'D');
|
wolffd@0
|
26 %engine{end+1} = jtree_ndx_dbn_inf_engine(bnet, 'ndx_type', 'B');
|
wolffd@0
|
27 if USEC, engine{end+1} = jtree_C_dbn_inf_engine(bnet); end
|
wolffd@0
|
28 engine{end+1} = hmm_inf_engine(bnet);
|
wolffd@0
|
29 engine{end+1} = jtree_unrolled_dbn_inf_engine(bnet, T);
|
wolffd@0
|
30
|
wolffd@0
|
31 % times in matlab N=4 Q=4 T=5 (* = winner)
|
wolffd@0
|
32 % jtree SD B hmm dhmm unrolled
|
wolffd@0
|
33 % 0.6266 1.1563 8.3815 0.3069 0.1948* 0.8654 inf
|
wolffd@0
|
34 % 0.9057* 2.1522 12.6314 2.6847 2.3107 3.1905 learn
|
wolffd@0
|
35
|
wolffd@0
|
36 %engine{end+1} = bk_inf_engine(bnet, 'ff', onodes);
|
wolffd@0
|
37 %engine{end+1} = pearl_unrolled_dbn_inf_engine(bnet, T);
|
wolffd@0
|
38
|
wolffd@0
|
39 inf_time = cmp_inference_dbn(bnet, engine, T)
|
wolffd@0
|
40 learning_time = cmp_learning_dbn(bnet, engine, T)
|
wolffd@0
|
41
|