Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_kernel/Old/tabular_kernel.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function K = tabular_kernel(fg, self) |
wolffd@0 | 2 % TABULAR_KERNEL Make a table-based local kernel (discrete potential) |
wolffd@0 | 3 % K = tabular_kernel(fg, self) |
wolffd@0 | 4 % |
wolffd@0 | 5 % fg is a factor graph |
wolffd@0 | 6 % self is the number of a representative domain |
wolffd@0 | 7 % |
wolffd@0 | 8 % Use 'set_params_kernel' to adjust the following fields |
wolffd@0 | 9 % table - a q[1]xq[2]x... array, where q[i] is the number of values for i'th node |
wolffd@0 | 10 % in this domain [default: random values from [0,1], which need not sum to 1] |
wolffd@0 | 11 |
wolffd@0 | 12 |
wolffd@0 | 13 if nargin==0 |
wolffd@0 | 14 % This occurs if we are trying to load an object from a file. |
wolffd@0 | 15 K = init_fields; |
wolffd@0 | 16 K = class(K, 'tabular_kernel'); |
wolffd@0 | 17 return; |
wolffd@0 | 18 elseif isa(fg, 'tabular_kernel') |
wolffd@0 | 19 % This might occur if we are copying an object. |
wolffd@0 | 20 K = fg; |
wolffd@0 | 21 return; |
wolffd@0 | 22 end |
wolffd@0 | 23 K = init_fields; |
wolffd@0 | 24 |
wolffd@0 | 25 ns = fg.node_sizes; |
wolffd@0 | 26 dom = fg.doms{self}; |
wolffd@0 | 27 % we don't store the actual domain since it may vary due to parameter tieing |
wolffd@0 | 28 K.sz = ns(dom); |
wolffd@0 | 29 K.table = myrand(K.sz); |
wolffd@0 | 30 |
wolffd@0 | 31 K = class(K, 'tabular_kernel'); |
wolffd@0 | 32 |
wolffd@0 | 33 |
wolffd@0 | 34 %%%%%%% |
wolffd@0 | 35 |
wolffd@0 | 36 |
wolffd@0 | 37 function K = init_fields() |
wolffd@0 | 38 % This ensures we define the fields in the same order |
wolffd@0 | 39 % no matter whether we load an object from a file, |
wolffd@0 | 40 % or create it from scratch. (Matlab requires this.) |
wolffd@0 | 41 |
wolffd@0 | 42 K.table = []; |
wolffd@0 | 43 K.sz = []; |
wolffd@0 | 44 |
wolffd@0 | 45 |