quimb.tensor.belief_propagation.regions¶
Region graph functionality - for GBP and cluster expansions.
Classes¶
A graph of regions, where each region is a set of nodes. For generalized |
Functions¶
|
Decorator for caching information about regions. |
Module Contents¶
- quimb.tensor.belief_propagation.regions.cached_region_property(name)¶
Decorator for caching information about regions.
- class quimb.tensor.belief_propagation.regions.RegionGraph(regions=(), autocomplete=True, autoprune=True)¶
A graph of regions, where each region is a set of nodes. For generalized belief propagation or cluster expansion methods.
- Parameters:
- lookup¶
- parents¶
- children¶
- info¶
- reset_info()¶
Remove all cached region properties.
- property regions¶
- get_overlapping(region)¶
Get all regions that intersect with the given region.
- add_region(region)¶
Add a new region and update parent-child relationships.
- Parameters:
region (Sequence[Hashable]) – The new region to add.
- remove_region(region)¶
Remove a region and update parent-child relationships.
- autocomplete()¶
Add all missing intersecting sub-regions.
- autoprune()¶
Remove all regions with a count of zero.
- autoextend(regions=None)¶
Extend this region graph upwards by adding in all pairwise unions of regions. If regions is specified, take this as one set of pairs.
- get_parents(region)¶
Get all ancestors that contain the given region, but do not contain any other regions that themselves contain the given region.
- get_children(region)¶
Get all regions that are contained by the given region, but are not contained by any other descendents of the given region.
- get_ancestors(region)¶
Get all regions that contain the given region, not just direct parents.
- get_descendents(region)¶
Get all regions that are contained by the given region, not just direct children.
- get_coparent_pairs(region)¶
Get all regions which are direct parents of any descendant of the given region, but not themselves descendants of the given region.
- get_count(region)¶
Get the count of the given region, i.e. the correct weighting to apply when summing over all regions to avoid overcounting.
- get_total_count()¶
Get the total count of all regions.
- get_level(region)¶
Get the level of the given region, i.e. the distance to an ancestor with no parents.
- get_message_parts(pair)¶
Get the three contribution groups for a GBP message from region source to region target. 1. The part of region source that is not part of target, i.e. the factors to include. 2. The messages that appear in the numerator of the update equation. 3. The messages that appear in the denominator of the update equation.
- Parameters:
source (Region) – The source region, should be a parent of target.
target (Region) – The target region, should be a child of source.
- Returns:
factors (Region) – The difference of source and target, which will include the factors to appear in the numerator of the update equation.
pairs_mul (set[(Region, Region)]) – The messages that appear in the numerator of the update equation, after cancelling out those that appear in the denominator.
pairs_div (set[(Region, Region)]) – The messages that appear in the denominator of the update equation, after cancelling out those that appear in the numerator.
- check()¶
Run some basic consistency checks on the region graph.
- draw(pos=None, a=20, scale=1.0, radius=0.1, **drawing_opts)¶
- __repr__()¶