Factors
Factors organize the interactions between variables and synthesize them into interaction groups. A FactorSamplingProgram wraps a set of factors into a runnable sampler.
AbstractFactorclassAbstractFactor(node_groups: list[Block])A factor represents a batch of undirected interactions between sets of random variables.
Concretely, this class implements a batch of factors defined over a bunch of parallel node groups. A single factor is defined over the nodes given by node_groups[k][i] for all k and a particular i. The defining trait of a factor is to produce InteractionGroups that affect each member of the factor in some way during the conditional updates of a block sampling program. As a user, you specify how this is done by implementing a concrete to_interaction_groups method for your child class.
Attributes:
node_groups: the list of blocks that makes up this batch of factors.
WeightedFactorclassWeightedFactor(weights: Array, node_groups: list[Block])A factor that is parameterized by a weight tensor.
The leading dimension of the weights tensor must be the same length as the batch dimension of the factor (i.e the number of nodes in each of the node_groups).
Attributes:
weights: the weight tensor.
FactorSamplingProgramclassFactorSamplingProgram(gibbs_spec: BlockGibbsSpec, samplers: list[AbstractConditionalSampler], factors: Sequence[AbstractFactor], other_interaction_groups: list[InteractionGroup])A sampling program built out of factors.
This class simply breaks each factor passed to it down into interaction groups and uses them to build a BlockSamplingProgram.