Skip to content

Commit

Permalink
Check grammar in more doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnusKoudahl committed Jul 5, 2022
1 parent 705635e commit a60c944
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions docs/src/lib/nodes/nodes.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

# [Nodes implementation](@id lib-node)

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

!!! note
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)`.
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)`.

## [Adding a custom node](@id lib-custom-node)

`ReactiveMP.jl` exports `@node` macro that allows a quick definition of a factor node with __fixed__ number of edges. The interface is the following:
`ReactiveMP.jl` exports the `@node` macro that allows for quick definition of a factor node with a __fixed__ number of edges. The interface is the following:

```julia
struct MyNewCustomNode end
Expand All @@ -22,13 +22,13 @@ struct MyNewCustomNode end
# `Deterministic`
```

This expression registers a new node that can be used with inference engine. Note, however, that `@node` macro does not generate any message passing update rules.
These must be defined using the `@rule` macro.
This expression registers a new node that can be used with the inference engine. Note howeve, that the `@node` macro does not generate any message passing update rules.
These must be defined using the `@rule` macro.

## [Node types](@id lib-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`](@ref) or [`Stochastic`](@ref) functional form type.
We distinguish different types of factor nodes in order to have better control over Bethe Free Energy computation.
Each factor node has either the [`Deterministic`](@ref) or [`Stochastic`](@ref) functional form type.

```@docs
Deterministic
Expand All @@ -42,7 +42,7 @@ sdtype
using ReactiveMP
```

For example `+` node has the [`Deterministic`](@ref) type:
For example the `+` node has the [`Deterministic`](@ref) type:

```@example lib-node-types
plus_node = make_node(+)
Expand All @@ -52,7 +52,7 @@ println("Is `+` node stochastic: ", isstochastic(plus_node))
nothing #hide
```

On the other hand `Bernoulli` node has the [`Stochastic`](@ref) type:
On the other hand, the `Bernoulli` node has the [`Stochastic`](@ref) type:

```@example lib-node-types
bernoulli_node = make_node(Bernoulli)
Expand All @@ -71,20 +71,20 @@ nothing #hide

## [Node functional dependencies pipeline](@id lib-node-functional-dependencies-pipeline)

Generic implementation of factor node in ReactiveMP supports custom functional dependencies pipelines. In a few words, __functional dependencies pipeline__ defines what
dependencies are need to compute a single message. As an example consider belief-propagation message update equation for a factor node $f$ with three edges: $x$, $y$ and $z$:
The generic implementation of factor nodes in ReactiveMP supports custom functional dependency pipelines. Briefly, the __functional dependencies pipeline__ defines what
dependencies are need to compute a single message. As an example, consider the belief-propagation message update equation for a factor node $f$ with three edges: $x$, $y$ and $z$:

```math
\mu(x) = \int \mu(y) \mu(z) f(x, y, z) \mathrm{d}y \mathrm{d}z
```

Here we see that, in standard setting, for belief-propagation message out of edge $x$ we need only messages from edges $y$ and $z$. In contrast, consider variational message update rule equation with mean-field assumption:
Here we see that in the standard setting for the belief-propagation message out of edge $x$, we need only messages from the edges $y$ and $z$. In contrast, consider the variational message update rule equation with mean-field assumption:

```math
\mu(x) = \exp \int q(y) q(z) \log f(x, y, z) \mathrm{d}y \mathrm{d}z
```

We see that, in this setting, we do not need messages $\mu(y)$ and $\mu(z)$, but only marginals $q(y)$ and $q(z)$. The purpose of a __functional dependencies pipeline__ is to determine functional dependencies (set of messages or marginals) that are needed to compute a single message. By default, `ReactiveMP.jl` uses a so-called `DefaultFunctionalDependencies` that correctly implements belief-propagation and variational message passing schemes (includes both mean-field and structured). The full list of built-in pipelines is present below:
We see that in this setting, we do not need messages $\mu(y)$ and $\mu(z)$, but only the marginals $q(y)$ and $q(z)$. The purpose of a __functional dependencies pipeline__ is to determine functional dependencies (a set of messages or marginals) that are needed to compute a single message. By default, `ReactiveMP.jl` uses so-called `DefaultFunctionalDependencies` that correctly implements belief-propagation and variational message passing schemes (including both mean-field and structured factorisations). The full list of built-in pipelines is presented below:

```@docs
DefaultFunctionalDependencies
Expand All @@ -95,7 +95,7 @@ RequireEverythingFunctionalDependencies

## [Node traits](@id lib-node-traits)

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

!!! note
[`@node`](@ref) macro does that automatically
Expand All @@ -104,4 +104,4 @@ Each factor node has to define [`as_node_functional_form`](@ref) trait function
ValidNodeFunctionalForm
UndefinedNodeFunctionalForm
as_node_functional_form
```
```

0 comments on commit a60c944

Please sign in to comment.