Model specification in RxInfer
RxInfer.@model
— Macro@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 forOR(a, b)
node (operator precedence between||
,&&
,->
and!
is the same as in Julia).a && b
: alias forAND(a, b)
node (operator precedence||
,&&
,->
and!
is the same as in Julia).a -> b
: alias forIMPLY(a, b)
node (operator precedence||
,&&
,->
and!
is the same as in Julia).¬a
and!a
: alias forNOT(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 forNormalMeanVariance(..., ...)
node.Gaussian
could be used insteadNormal
too.Normal(μ|m|mean = ..., τ|γ|σ⁻²|w|p|prec|precision = ...)
alias forNormalMeanPrecision(..., ...)
node.Gaussian
could be used insteadNormal
too.MvNormal(μ|m|mean = ..., Σ|V|Λ⁻¹|cov|covariance = ...)
alias forMvNormalMeanCovariance(..., ...)
node.MvGaussian
could be used insteadMvNormal
too.MvNormal(μ|m|mean = ..., Λ|W|Σ⁻¹|prec|precision = ...)
alias forMvNormalMeanPrecision(..., ...)
node.MvGaussian
could be used insteadMvNormal
too.MvNormal(μ|m|mean = ..., τ|γ|σ⁻²|scale_diag_prec|scale_diag_precision = ...)
alias forMvNormalMeanScalePrecision(..., ...)
node.MvGaussian
could be used insteadMvNormal
too.Gamma(α|a|shape = ..., θ|β⁻¹|scale = ...)
alias forGammaShapeScale(..., ...) node.
Gamma(α|a|shape = ..., β|θ⁻¹|rate = ...)
alias forGammaShapeRate(..., ...) node.
RxInfer.ModelGenerator
— TypeModelGenerator
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
RxInfer.create_model
— Functioncreate_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:
- an instance of
FactorGraphModel
- an instance of
- return value from the
@model
macro function definition
- return value from the
RxInfer.ModelInferenceOptions
— TypeModelInferenceOptions(; 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 withStackOverflowError
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 tofalse
. Defaults totrue
.
Advanced options
pipeline
: changes the default pipeline for each factor node in the graphglobal_reactive_scheduler
: changes the scheduler of reactive streams, see Rocket.jl for more info, defaults to no scheduler
See also: inference
, rxinference