Energy-based models
Energy-based models define a distribution through an energy function. THRML factorizes that energy so block Gibbs can sample it.
AbstractEBMclassAbstractEBM()Something that has a well-defined energy function (map from a state to a scalar).
energymethodenergy(state: list[PyTree[Shaped[Array, 'nodes ?*state'], '_State']], blocks: list[Block]) -> Float[Array, '']Evaluate the energy function of the EBM given some state information.
Arguments:
state: The state for which to evaluate the energy function. Must be compatible withblocks.blocks: Specifies how the information instateis organized.
Returns:
A scalar representing the energy value associated with state.
AbstractFactorizedEBMclassAbstractFactorizedEBM(node_shape_dtypes: Mapping[Type[AbstractNode], PyTree[jax.ShapeDtypeStruct]] = {SpinNode: ShapeDtypeStruct(shape=(), dtype=bool), CategoricalNode: ShapeDtypeStruct(shape=(), dtype=uint8)})An EBM that is made up of Factors, i.e., an EBM with an energy function like,
where the sum over $i$ is taken over factors.
Child classes must define a property which returns a list of factors that substantiate the EBM.
Attributes:
node_shape_dtypes: the shape/dtypes of the nodes involved in this EBM. Used to generate the BlockSpec that defines the global state that factors receive to compute energy.
node_shape_dtypesattributenode_shape_dtypes: Mapping[Type[AbstractNode], PyTree[jax.ShapeDtypeStruct]]energymethodenergy(state: list[PyTree[Shaped[Array, 'nodes ?*state'], '_State']], blocks: list[Block]) -> Float[Array, '']Evaluate the energy function of the EBM given some state information.
Arguments:
state: The state for which to evaluate the energy function. Must be compatible withblocks.blocks: Specifies how the information instateis organized.
Returns:
A scalar representing the energy value associated with state.
factorspropertyfactorsA concrete implementation of this class must define this method that returns a list of factors that substantiate the EBM.
FactorizedEBMclassFactorizedEBM(factors: list[EBMFactor], node_shape_dtypes: Mapping[Type[AbstractNode], PyTree[jax.ShapeDtypeStruct]] = {SpinNode: ShapeDtypeStruct(shape=(), dtype=bool), CategoricalNode: ShapeDtypeStruct(shape=(), dtype=uint8)})An EBM that is defined by a concrete list of factors.
Attributes:
_factors: the list of factors that defines this EBM.
node_shape_dtypesattributenode_shape_dtypes: Mapping[Type[AbstractNode], PyTree[jax.ShapeDtypeStruct]]energymethodenergy(state: list[PyTree[Shaped[Array, 'nodes ?*state'], '_State']], blocks: list[Block]) -> Float[Array, '']Evaluate the energy function of the EBM given some state information.
Arguments:
state: The state for which to evaluate the energy function. Must be compatible withblocks.blocks: Specifies how the information instateis organized.
Returns:
A scalar representing the energy value associated with state.
factorspropertyfactorsEBMFactorclassEBMFactor(node_groups: list[Block])A factor that defines an energy function.
node_groupsattributenode_groups: list[Block]energymethodenergy(global_state: list[Array], block_spec: BlockSpec) -> Float[Array, '']Evaluate the energy function of the factor.
Arguments:
global_state: The state information to use to evaluate the energy function. Is a global state ofblock_spec.block_spec: TheBlockSpecused to generateglobal_state.
to_interaction_groupsmethodto_interaction_groups() -> list[InteractionGroup]Compile a factor to a set of directed interactions.