Delta node
ReactiveMP.DeltaMeta — TypeDeltaMeta(method = ..., [ inverse = ... ])DeltaMeta structure specifies the approximation method for the outbound messages in the DeltaFn node.
Arguments
method: required, the approximation method, currently supported methods areLinearization,UnscentedandCVI.inverse: optional, if no inverse provided, the backward rule will be computed based on RTS (Petersen et al. 2018; On Approximate Delta Gaussian Message Passing on Factor Graphs)
Is is also possible to pass the AbstractApproximationMethod to the meta of the delta node directly. In this case inverse is set to nothing.
ReactiveMP.ManyOf — TypeSome nodes use IndexedInterface, ManyOf structure reflects a collection of marginals from the collection of IndexedInterfaces. @rule macro also treats ManyOf specially.
ReactiveMP.Linearization — TypeThe Linearization structure defines the approximation method of the Delta and Flow factor nodes. This method performs a local linearization of f around expansion point x.
The Linearization structure with default parameters can be constructed as Linearization().
The Linearization structure is used inside the DeltaMeta or FlowMeta structures and can be included as:
y ~ f(x) where { meta = DeltaMeta(method = Linearization()) }
# or
y ~ Flow(x) where { meta = FlowMeta(flowmodel, Linearization()) }ReactiveMP.local_linearization — Functionlocal_linearization(g, x)Returns linear components (a, b) for the function g at the point x.
ReactiveMP.smoothRTS — FunctionRTS smoother update for inbound marginal; based on (Petersen et al. 2018; On Approximate Delta Gaussian Message Passing on Factor Graphs)
ReactiveMP.Unscented — TypeThe Unscented structure defines the approximation method of the Delta and Flow factor nodes. More specifically, it contains the hyperparameters used for sigma points computation.
Arguments
α: Spread parameter for unscented transform #1β: Algorithm parameter for incorporating prior information on the (non-Gaussian) distribution of Delta node inputκ: Spread parameter for unscented transform #2e: Internal cache
The Unscented structure with default parameters can be constructed as Unscented().
The Unscented structure is used inside the DeltaMeta or FlowMeta structure and can be included as:
y ~ f(x) where { meta = DeltaMeta(method = Unscented()) }
# or
y ~ Flow(x) where { meta = FlowMeta(flowmodel, Unscented()) }ReactiveMP.sigma_points_weights — FunctionReturn the sigma points and weights for a Gaussian distribution
ReactiveMP.CVIApproximationDeltaFnRuleLayout — TypeCVIApproximationDeltaFnRuleLayoutCustom rule layout for the Delta node in case of the CVI approximation method:
Layout
In order to compute:
q_out: mirrors the posterior marginal on theoutedgeq_ins: uses inbound message on theoutedge and all inbound messages on theinsedgesm_out: uses the joint over theinsedgesm_in_k: uses the inbound message on thein_kedge andq_ins
ReactiveMP.log_approximate — FunctionThis function calculates the log of the Gauss-laguerre integral by making use of the log of the integrable function. ln ( ∫ exp(-x)f(x) dx ) ≈ ln ( ∑ wi * f(xi) ) = ln ( ∑ exp( ln(wi) + logf(xi) ) ) = ln ( ∑ exp( yi ) ) = max(yi) + ln ( ∑ exp( yi - max(yi) ) ) where we make use of the numerically stable log-sum-exp trick: https://en.wikipedia.org/wiki/LogSumExp
ReactiveMP.ForwardDiffGrad — TypeForwardDiffGrad(chunk_size::Int)The auto-differentiation backend for the CVI procedure. Uses the ForwardDiff library to compute gradients/derivatives. If chunk_size is not specified then uses the heuristic from ForwardDiff, which is type-unstable.
The ForwardDiff.jl must be added to the current Julia environment.
ReactiveMP.UT — TypeAn alias for the Unscented approximation method.
ReactiveMP.UnscentedTransform — TypeAn alias for the Unscented approximation method.
ReactiveMP.ProdCVI — TypeProdCVIThe ProdCVI structure defines the approximation method hyperparameters of the prod(approximation::CVI, logp::F, dist). This method performs an approximation of the product of the dist and logp with Stochastic Variational message passing (SVMP-CVI) (See Probabilistic programming with stochastic variational message passing).
Arguments
rng: random number generatorn_samples: number of samples to use for statistics approximationn_iterations: number of iteration for the natural parameters gradient optimizationopt: optimizer, which will be used to perform the natural parameters gradient optimization stepgrad: optional, defaults toForwardDiffGrad(), structure to select how the gradient and the hessian will be computedn_gradpoints: optional, defaults to 1, number of points to estimate gradient of the likelihood (dist*logp)enforce_proper_messages: optional, defaults to true, ensures that a message, computed towards the inbound edges, is a proper distribution, must be of typeVal(true)/Val(false)warn: optional, defaults to true, enables or disables warnings related to the optimization steps
n_gradpoints option is ignored in the Gaussian case
Adding the Optimisers.jl in your Julia environment enables additional optimizers from the Optimisers.jl for the CVI approximation method. Adding the DiffResults in your Julia environment enables faster gradient computations in case if all inputs are of the Gaussian type.
ReactiveMP.CVI — TypeAlias for the ProdCVI method. See help for ProdCVI
ReactiveMP.cvi_setup! — Functioncvi_setup!(opt, λ)Initialises the given optimiser for the CVI procedure given the structure of λ. Returns a tuple of the optimiser and the optimiser state.
ReactiveMP.cvi_update! — Functioncvi_update!(tuple_of_opt_and_state, new_λ, λ, ∇)Uses the optimiser, its state and the gradient ∇ to change the trainable parameters in the λ. Modifies the optimiser state and and store the output in the newλ. Returns a tuple of the optimiser and the newλ.
ReactiveMP.DeltaFnDefaultRuleLayout — TypeDeltaFnDefaultRuleLayoutDefault rule layout for the Delta node:
Layout
In order to compute:
q_out: mirrors the posterior marginal on theoutedgeq_ins: uses inbound message on theoutedge and all inbound messages on theinsedgesm_out: uses all inbound messages on theinsedgesm_in_k: uses the inbound message on thein_kedge andq_ins
ReactiveMP.DeltaFnDefaultKnownInverseRuleLayout — TypeDeltaFnDefaultKnownInverseRuleLayoutDefault rule layout for the Delta node:
Layout
In order to compute:
q_out: mirrors the posterior marginal on theoutedge (same as theDeltaFnDefaultRuleLayout)q_ins: uses inbound message on theoutedge and all inbound messages on theinsedges (same as theDeltaFnDefaultRuleLayout)m_out: uses all inbound messages on theinsedges (same as theDeltaFnDefaultRuleLayout)m_in_k: uses inbound message on theoutedge and inbound messages on theinsedges exceptk