Model specification in RxInfer

RxInfer.@modelMacro
@model function model_name(model_arguments...; model_keyword_arguments...)
    # model description
end

@model macro generates a function that returns an equivalent graph-representation of the given probabilistic model description.

Supported alias in the model specification

  • a || b: alias for OR(a, b) node (operator precedence between ||, &&, -> and ! is the same as in Julia).
  • a && b: alias for AND(a, b) node (operator precedence ||, &&, -> and ! is the same as in Julia).
  • a -> b: alias for IMPLY(a, b) node (operator precedence ||, &&, -> and ! is the same as in Julia).
  • ¬a and !a: alias for NOT(a) node (Unicode \neg, operator precedence ||, &&, -> and ! is the same as in Julia).
  • a + b + c: alias for (a + b) + c
  • a * b * c: alias for (a * b) * c
  • Normal(μ|m|mean = ..., σ²|τ⁻¹|v|var|variance = ...) alias for NormalMeanVariance(..., ...) node. Gaussian could be used instead Normal too.
  • Normal(μ|m|mean = ..., τ|γ|σ⁻²|w|p|prec|precision = ...) alias for NormalMeanPrecision(..., ...) node. Gaussian could be used instead Normal too.
  • MvNormal(μ|m|mean = ..., Σ|V|Λ⁻¹|cov|covariance = ...) alias for MvNormalMeanCovariance(..., ...) node. MvGaussian could be used instead MvNormal too.
  • MvNormal(μ|m|mean = ..., Λ|W|Σ⁻¹|prec|precision = ...) alias for MvNormalMeanPrecision(..., ...) node. MvGaussian could be used instead MvNormal too.
  • MvNormal(μ|m|mean = ..., τ|γ|σ⁻²|scale_diag_prec|scale_diag_precision = ...) alias for MvNormalMeanScalePrecision(..., ...) node. MvGaussian could be used instead MvNormal too.
  • Gamma(α|a|shape = ..., θ|β⁻¹|scale = ...) alias for GammaShapeScale(..., ...) node.
  • Gamma(α|a|shape = ..., β|θ⁻¹|rate = ...) alias for GammaShapeRate(..., ...) node.
source
RxInfer.ModelGeneratorType
ModelGenerator

ModelGenerator is a special object that is used in the inference function to lazily create model later on given constraints, meta and options.

See also: inference

source
RxInfer.create_modelFunction
create_model(::ModelGenerator, constraints = nothing, meta = nothing, options = nothing)

Creates an instance of FactorGraphModel from the given model specification as well as optional constraints, meta and options.

Returns a tuple of 2 values:

    1. an instance of FactorGraphModel
    1. return value from the @model macro function definition
source
RxInfer.ModelInferenceOptionsType
ModelInferenceOptions(; kwargs...)

Creates model inference options object. The list of available options is present below.

Options

  • limit_stack_depth: limits the stack depth for computing messages, helps with StackOverflowError for some huge models, but reduces the performance of inference backend. Accepts integer as an argument that specifies the maximum number of recursive depth. Lower is better for stack overflow error, but worse for performance.
  • warn: (optional) flag to suppress warnings. Warnings are not displayed if set to false. Defaults to true.

Advanced options

  • pipeline: changes the default pipeline for each factor node in the graph
  • global_reactive_scheduler: changes the scheduler of reactive streams, see Rocket.jl for more info, defaults to no scheduler

See also: inference, rxinference

source