Can you please advice how one can model Markov random field in Infer.NET? I'd like to implement a simple image segmentation algorithm, but I'm really unsure about the way of specifying clique potentials in the model.
Thanks in advance.
You can specify clique potentials using constraints or soft constraints. For example, if you want a potential which is 0.2 when x1==x2 and 0.8 otherwise, you can say: Variable.ConstrainEqualRandom(x1==x2, new Bernoulli(0.2));which is equivalent to: Variable.ConstrainEqual(x1==x2, Variable.Bernoulli(0.2));The latter form is preferable if you want 0.2 to be a parameter of the model. For example: Variable<double> p = Variable.Beta(1,1); Variable.ConstrainEqual(x1==x2, Variable.Bernoulli(p)); Variable.ConstrainEqual(x2==x3, Variable.Bernoulli(p)); etc.
Whilst you can construct this model in Infer.NET, as Tom describes, you should be aware that Infer.NET does not yet handle large grid models efficiently - such as would be needed to segment a normal sized image. This is a high priority feature and we intend to support it in a forthcoming release.
Best regards,
John W.