Skip to content

About

The ContinuousTransition node for message passing: a transition through a matrix built from a vector

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

30 Commits

Folders and files

Repository files navigation

ContinuousTransitionMessagePassingRules

CI Docs: stable Docs: dev Coverage Code style: Runic

The ContinuousTransition node, y ~ N(f(a) x, W⁻¹) (alias CTransition): a linear Gaussian transition from x to y through a matrix built from the vector a, with a and the noise precision W learned along with the states. Its rules are variational, mean-field or structured q(y, x), with average energies, and run under CTVMP(f), which carries the transformation f and which a model must give. A nonlinear f is linearised with ForwardDiff.

using ContinuousTransitionMessagePassingRules, MessagePassingRulesBase, ExponentialFamily

result = @call_message_update_rule(
    node = ContinuousTransition, target = :y, algorithm = CTVMP(a -> reshape(a, 1, 1)),
    q = (x = MvNormalMeanCovariance([2.0], [1.0;;]), a = MvNormalMeanCovariance([3.0], [1.0;;]), W = Wishart(2, [0.5;;])),
)
getresult(result)   # MvNormalMeanPrecision([6.0], [1.0;;])

For a matrix learned entry by entry, use LinearContinuousTransition with LCTVMP(n, m): it computes the same rules as CTVMP(a -> reshape(a, n, m)) without Jacobians or linearisation. a = vec(A) uses Julia's column-major ordering. LCTVMP supplies only the shape; the factorisation still selects ordinary mean-field or structured VMP. Messages to a need no expansion point, and the inference engine reuses scratch matrices per message stream without overwriting earlier results.

result = @call_message_update_rule(
    node = LinearContinuousTransition, target = :y, algorithm = LCTVMP(1, 1),
    q = (x = MvNormalMeanCovariance([2.0], [1.0;;]), a = MvNormalMeanCovariance([3.0], [1.0;;]), W = Wishart(2, [0.5;;])),
)
import Pkg; Pkg.add("ContinuousTransitionMessagePassingRules")
  • Documentation: https://reactivebayes.github.io/ContinuousTransitionMessagePassingRules.jl/stable/. make docs builds it locally, into docs/build.
  • Tests: make test runs the suite as CI does, ending with the rule-coverage gate: every rule must be selected by some test. make test test_args="name:rules" selects items by tag, by name or by file; make help lists the other targets.
  • Julia 1.10 or later. MIT licence.

To compare all rules against reshape-based CTVMP, including runtime and allocations with reused scratch, run from the repository root:

julia --project=benchmark -e 'import Pkg; Pkg.develop(path="."); Pkg.instantiate()'
julia --project=benchmark benchmark/linear.jl

About

The ContinuousTransition node for message passing: a transition through a matrix built from a vector

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages