quimb.experimental.belief_propagation.hd1gbp

Classes

HD1GBP

Generalized belief propagation for hyper tensor networks.

Functions

auto_add_indices(tn, regions)

Make sure all indices incident to any tensor in each region are

Module Contents

quimb.experimental.belief_propagation.hd1gbp.auto_add_indices(tn, regions)

Make sure all indices incident to any tensor in each region are included in the region.

class quimb.experimental.belief_propagation.hd1gbp.HD1GBP(tn: quimb.tensor.TensorNetwork, regions, *, autocomplete=True, autoprune=True, damping=1 / 2, optimize='auto-hq', **kwargs)

Bases: quimb.tensor.belief_propagation.bp_common.BeliefPropagationCommon

Generalized belief propagation for hyper tensor networks.

Parameters:
  • tn (TensorNetwork) – The hyper tensor network to run GBP on.

  • regions (sequence[sequence[int | str]]) – The regions to use for GBP. Each region can be a set of tids and indices. If a tid is present in a region, all its indices are automatically included in the region when autocomplete=True.

  • autocomplete (bool, optional) – Whether to automatically compute all intersection subregions for the RegionGraph.

  • autoprune (bool, optional) – Whether to automatically remove all regions with a count of zero.

  • damping (float, optional) – The damping factor to use for the messages.

  • optimize (str, optional) – The contraction path optimization strategy to use.

rg
messages
new_messages
contract_opts
get_message_tensors(source, target)

Get all message tensors needed to compute the message from source to target.

compute_message(source, target, **contract_opts)

Compute the message from source to target region.

Parameters:
  • source (Region) – The source region.

  • target (Region) – The target region.

  • contract_opts – Supplied to tensor_contract().

iterate(tol=5e-06)

Perform a single iteration of belief propagation. Subclasses should implement this method, returning either max_mdiff or a dictionary containing max_mdiff and any other relevant information:

{

“nconv”: nconv, “ncheck”: ncheck, “max_mdiff”: max_mdiff,

}

get_belief_tensors(region)

Get the (uncontracted) tensors for the belief of region.

contract(strip_exponent=False, check_zero=True)

Contract this tensor network given the current GBP messages.

Parameters:

sstrip_exponent (bool, optional) – Whether to strip the exponent from the final result. If True then the returned result is (mantissa, exponent).

Returns:

result – The combined value, or the mantissa and exponent separately.

Return type:

float or (float, float)

draw(rhighlight=None, zfactor=2)