Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/static/@belprop_fg_inf_engine/belprop_fg_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 = belprop_fg_inf_engine(fg, varargin) | |
2 % BELPROP_FG_INF_ENGINE Make a belief propagation inference engine for factor graphs | |
3 % engine = belprop_fg_inf_engine(factor_graph, ...) | |
4 % | |
5 % The following optional arguments can be specified in the form of name/value pairs: | |
6 % [default in brackets] | |
7 % e.g., engine = belprop_inf_engine(fg, 'tol', 1e-2, 'max_iter', 10) | |
8 % | |
9 % max_iter - max. num. iterations [ 2*num_nodes ] | |
10 % momentum - weight assigned to old message in convex combination (useful for damping oscillations) [0] | |
11 % tol - tolerance used to assess convergence [1e-3] | |
12 % maximize - 1 means use max-product, 0 means use sum-product [0] | |
13 % | |
14 % This uses potential objects, like belprop_inf_engine, and hence is quite slow. | |
15 | |
16 engine = init_fields; | |
17 engine = class(engine, 'belprop_fg_inf_engine'); | |
18 | |
19 % set params to default values | |
20 N = length(fg.G); | |
21 engine.max_iter = 2*N; | |
22 engine.momentum = 0; | |
23 engine.tol = 1e-3; | |
24 engine.maximize = 0; | |
25 | |
26 % parse optional arguments | |
27 engine = set_params(engine, varargin); | |
28 | |
29 engine.fgraph = fg; | |
30 | |
31 % store results computed by enter_evidence here | |
32 engine.marginal_nodes = cell(1, fg.nvars); | |
33 engine.evidence = []; | |
34 | |
35 | |
36 %%%%%%%%%%%% | |
37 | |
38 function engine = init_fields() | |
39 | |
40 engine.fgraph = []; | |
41 engine.max_iter = []; | |
42 engine.momentum = []; | |
43 engine.tol = []; | |
44 engine.maximize = []; | |
45 engine.marginal_nodes = []; | |
46 engine.evidence = []; | |
47 engine.niter = []; |