Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/dynamic/@jtree_unrolled_dbn_inf_engine/jtree_unrolled_dbn_inf_engine.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 function engine = jtree_unrolled_dbn_inf_engine(bnet, T, varargin) | |
2 % JTREE_UNROLLED_DBN_INF_ENGINE Unroll the DBN for T time-slices and apply jtree to the resulting static net | |
3 % engine = jtree_unrolled_dbn_inf_engine(bnet, T, ...) | |
4 % | |
5 % The following optional arguments can be specified in the form of name/value pairs: | |
6 % [default value in brackets] | |
7 % | |
8 % useC - 1 means use jtree_C_inf_engine instead of jtree_inf_engine [0] | |
9 % constrained - 1 means we constrain ourselves to eliminate slice t before t+1 [1] | |
10 % | |
11 % e.g., engine = jtree_unrolled_inf_engine(bnet, 'useC', 1); | |
12 | |
13 % set default params | |
14 N = length(bnet.intra); | |
15 useC = 0; | |
16 constrained = 1; | |
17 | |
18 if nargin >= 3 | |
19 args = varargin; | |
20 nargs = length(args); | |
21 if isstr(args{1}) | |
22 for i=1:2:nargs | |
23 switch args{i}, | |
24 case 'useC', useC = args{i+1}; | |
25 case 'constrained', constrained = args{i+1}; | |
26 otherwise, | |
27 error(['invalid argument name ' args{i}]); | |
28 end | |
29 end | |
30 else | |
31 error(['invalid argument name ' args{1}]); | |
32 end | |
33 end | |
34 | |
35 bnet2 = dbn_to_bnet(bnet, T); | |
36 ss = length(bnet.intra); | |
37 engine.ss = ss; | |
38 | |
39 % If constrained_order = 1 we constrain ourselves to eliminate slice t before t+1. | |
40 % This prevents cliques containing nodes from far-apart time-slices. | |
41 if constrained | |
42 stages = num2cell(unroll_set(1:ss, ss, T), 1); | |
43 else | |
44 stages = { 1:length(bnet2.dag) }; | |
45 end | |
46 if useC | |
47 jengine = jtree_C_inf_engine(bnet2, 'stages', stages); | |
48 else | |
49 jengine = jtree_inf_engine(bnet2, 'stages', stages); | |
50 end | |
51 | |
52 engine.unrolled_engine = jengine; | |
53 % we don't inherit from jtree_inf_engine, because that would only store bnet2, | |
54 % and we would lose access to the DBN-specific fields like intra/inter | |
55 | |
56 engine.nslices = T; | |
57 engine = class(engine, 'jtree_unrolled_dbn_inf_engine', inf_engine(bnet)); |