Internals
This page summarizes some of ForneyLab's internal structures. It is mainly tailored for software developers interested in a high-level overview of the inner workings of the package. Coding style conventions can be found in STYLEGUIDE.md.
Directory structure
ForneyLab's directories and files are structured as follows:
/demo/: demos in Jupyter (iJulia) notebook format (.ipynb)/docs/: documentation source and build location/src/: ForneyLab source filesalgorithms/: inference algorithm implementationsengines/: rendering of message passing schedules to executable codejulia/: Julia engine and update rule implementations
factor_nodes/: all node-specific filesupdate_rules/: message passing update rules
/test/: test files with directory structure similar to/src/.
InferenceAlgorithm data structure
A ForneyLab InferenceAlgorithm is structured as follows:
algorithm::InferenceAlgorithm: specifies everything required for algorithm generationposterior_factorization::PosteriorFactorization: specifies factorization of the posteriorposterior_factors::Vector{PosteriorFactor}(per item):id::Symbol: posterior factor idoptimize::Bool: require optimization blockinitialize::Bool: require initialization blockschedule::Schedule(perScheduleEntryitem):schedule_index::Int: position of entry in schedulemessage_update_rule::Type: update rule type for message computationinitialize::Bool: require message initializationfamily::FactorFunction: family of message distribution (for initialization)dimensionality::Tuple: dimensionality of message distribution (for initialization)inbounds::Vector(per item):inbound::Union: inbound, see below
marginal_table::MarginalTable(perMarginalEntryitem):marginal_id::Symbol: identifier for the marginalmarginal_update_rule::Union{Nothing, Product, Type}: update rule type for marginal computationinbounds::Vector(per item):inbound::Union: inbound, see below
average_energies::Dict(per item):node::Type: node type for average energy computationcounting_number::Int64: counting number for average energyinbounds::Vector(per item):inbound::Union: inbound, see below
entropies::Dict(per item):counting_number::Int64: counting number for (joint) entropyinbound::Union: inbound, see below
Inbounds are of type Union{Nothing, ScheduleEntry, MarginalEntry, Dict, Clamp}.
Update rules naming convention
The name of an update rule is composed of several parts:
- The word
rule - Type of algorithm
SP: sum-productVB: variational BayesSVB: structured variational BayesM: marginal (joint)
- Type of factor node
- Interface of the outgoing message
- Types of incoming messages (absent for
VBrules)N: NothingP: point massD: distribution[I]: first letter of the message's probability distribution
Example 1: ruleSPGaussianPrecisionMPNP
rule: update ruleSP: sum-product algorithmGaussianPrecision: Gaussian mean-precision parameterized factor nodeM: outgoing message through 'Mean' interfacePNP: incoming message types are: point mass, Nothing and point mass
Example 2: ruleVBBernoulliOut
rule: update ruleVB: variational Bayes algorithmBernoulli: Bernoulli factor nodeOut: outgoing message through 'Out' interface-
Example 3: ruleEPProbitIn1BG
rule: update ruleEP: expectation propagation algorithmProbit: probit factor nodeIn1: outgoing message through 'in1' interfaceGB: incoming message types are: Gaussian and Bernoulli
- Note that EP update rules do not have
N(nothing) in the set of incoming messages given that in EP there is an incoming message through the interface of the outgoing message that is being calculated.