Factors¤
thrml.AbstractFactor
¤
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.
to_interaction_groups() -> list[thrml.InteractionGroup]
¤
Compile a factor to a set of directed interactions.
thrml.WeightedFactor(thrml.AbstractFactor)
¤
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.
thrml.FactorSamplingProgram(thrml.BlockSamplingProgram)
¤
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.
__init__(gibbs_spec: thrml.BlockGibbsSpec, samplers: list[thrml.AbstractConditionalSampler], factors: Sequence[thrml.AbstractFactor], other_interaction_groups: list[thrml.InteractionGroup])
¤
Create a FactorSamplingProgram. Thin wrapper over BlockSamplingProgram.
Arguments:
gibbs_spec: A division of some PGM into free and clamped blocks.samplers: The update rule to use for each free block in gibbs_spec.factors: The factors to use to build this sampling program.other_interaction_groups: Other interaction groups to include in your program alongside what the factors produce.