May 16, 2009

Infer.Net | Stream of Variables

streams of variables
类似于 Matlab 的 comma seperated list

赋值时要求
streams of variables = another streams of variables

1) "Indexing variable array by range" 生成 streams of variables。
2)  Factor.ForEach(range) method 可以生成 streams of variables

所以
i) bools[pixel] = Variable.Bernoulli(0.7).ForEach(pixel);
是成立的。

ii) streams of variables 通过一个 factor (类似于一个算子) 还是一个 streams of variables。
bools[pixel] = !(Variable.Bernoulli(0.7).ForEach(pixel));
是成立的,!() 是一个 factor

iii)
若 allProbTrues 是一个概率值的 array,
bools[pixel] = Variable.Bernoulli(allProbTrues[pixel]);
是成立的。allProbTrues[pixel] 生成一个 streams of variables


Because streams are tagged with range objects, you can also combine multiple streams into one

expression yielding a multidimensional VariableArray, like so:

doubles2D[pixel,image] = y[pixel]+z[image];

这个是什么意思呢?


ForEach blocks
using(Variable.ForEach(pixel))
{
bools[pixel] = Variable.Bernoulli(0.7) | Variable.Bernoulli(0.4);

}

block 里每个新生成的 variable 都会带有 .ForEach(pixel)
这样可以省却麻烦。

            Variable<bool> t1;                      1
            t1 = Variable.Bernoulli(0.6);               2
            t1.ObservedValue = true;                    3

            Range d1 = new Range(2);
            VariableArray tvec = Variable.Array(d1);    1
            tvec[d1] = Variable.Bernoulli(0.6).ForEach(d1);                2
            tvec.ObservedValue = new bool[] { true,false};                 3

注意对应关系。

0 comments: