Nodes implementation

In message passing framework one of the most important concept is factor node. Factor node represents a local function in a factorised representation of a generative model.


To quickly check the list of all available factor nodes that can be used in the model specification language call ?make_node or Base.doc(make_node).

Node traits

Each factor node has to define as_node_functional_form trait function and to specify ValidNodeFunctionalForm singleton as a return object. By default as_node_functional_form returns UndefinedNodeFunctionalForm. Objects that do not specify this property correctly cannot be used in model specification.


@node macro does that automatically

Node types

We distinguish different types of factor nodes to have a better control over Bethe Free Energy computation. Each factor node has either Deterministic or Stochastic functional form type.

For example + node has the Deterministic type:

plus_node = make_node(+)

println("Is `+` node deterministic: ", isdeterministic(plus_node))
println("Is `+` node stochastic: ", isstochastic(plus_node))
Is `+` node deterministic: true
Is `+` node stochastic: false

On the other hand Bernoulli node has the Stochastic type:

bernoulli_node = make_node(Bernoulli)

println("Is `Bernoulli` node deterministic: ", isdeterministic(bernoulli_node))
println("Is `Bernoulli` node stochastic: ", isstochastic(bernoulli_node))
Is `Bernoulli` node deterministic: false
Is `Bernoulli` node stochastic: true

To get an actual instance of the type object we use sdtype function:

println("sdtype() of `+` node is ", sdtype(plus_node))
println("sdtype() of `Bernoulli` node is ", sdtype(bernoulli_node))
sdtype() of `+` node is Deterministic()
sdtype() of `Bernoulli` node is Stochastic()

Node factorisation constraints