quimb.experimental.belief_propagation.d1bp

Belief propagation for standard tensor networks. This:

  • assumes no hyper indices, only standard bonds.

  • assumes a single (‘dense’) tensor per site

  • works directly on the ‘1-norm’ i.e. scalar tensor network

This is the simplest version of belief propagation, and is useful for simple investigations.

Classes

D1BP

Dense (as in one tensor per site) 1-norm (as in for 'classical' systems)

Functions

initialize_messages(tn[, fill_fn])

contract_d1bp(tn[, max_iterations, tol, damping, ...])

Estimate the contraction of standard tensor network tn using dense

Module Contents

quimb.experimental.belief_propagation.d1bp.initialize_messages(tn, fill_fn=None)
class quimb.experimental.belief_propagation.d1bp.D1BP(tn, messages=None, damping=0.0, update='sequential', local_convergence=True, message_init_function=None)

Bases: quimb.experimental.belief_propagation.bp_common.BeliefPropagationCommon

Dense (as in one tensor per site) 1-norm (as in for ‘classical’ systems) belief propagation algorithm. Allows message reuse. This version assumes no hyper indices (i.e. a standard tensor network). This is the simplest version of belief propagation.

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

  • messages (dict[(str, int), array_like], optional) – The initial messages to use, effectively defaults to all ones if not specified.

  • damping (float, optional) – The damping factor to use, 0.0 means no damping.

  • update ({'sequential', 'parallel'}, optional) – Whether to update messages sequentially or in parallel.

  • local_convergence (bool, optional) – Whether to allow messages to locally converge - i.e. if all their input messages have converged then stop updating them.

  • fill_fn (callable, optional) – If specified, use this function to fill in the initial messages.

tn

The target tensor network.

Type:

TensorNetwork

messages

The current messages. The key is a tuple of the index and tensor id that the message is being sent to.

Type:

dict[(str, int), array_like]

key_pairs

A dictionary mapping the key of a message to the key of the message propagating in the opposite direction.

Type:

dict[(str, int), (str, int)]

tn
damping
local_convergence
update
backend
_abs
_sum
_normalize
_distance
touched
key_pairs
iterate(tol=5e-06)
normalize_messages()

Normalize all messages such that for each bond <m_i|m_j> = 1 and <m_i|m_i> = <m_j|m_j> (but in general != 1).

get_gauged_tn()

Gauge the original TN by inserting the BP-approximated transfer matrix eigenvectors, which may be complex. The BP-contraction of this gauged network is then simply the product of zeroth entries of each tensor.

contract(strip_exponent=False)
quimb.experimental.belief_propagation.d1bp.contract_d1bp(tn, max_iterations=1000, tol=5e-06, damping=0.0, update='sequential', local_convergence=True, strip_exponent=False, info=None, progbar=False, **contract_opts)

Estimate the contraction of standard tensor network tn using dense 1-norm belief propagation.

Parameters:
  • tn (TensorNetwork) – The tensor network to contract, it should have no dangling or hyper indices.

  • max_iterations (int, optional) – The maximum number of iterations to run for.

  • tol (float, optional) – The convergence tolerance for messages.

  • damping (float, optional) – The damping parameter to use, defaults to no damping.

  • update ({'sequential', 'parallel'}, optional) – Whether to update messages sequentially or in parallel.

  • local_convergence (bool, optional) – Whether to allow messages to locally converge - i.e. if all their input messages have converged then stop updating them.

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

  • info (dict, optional) – If specified, update this dictionary with information about the belief propagation run.

  • progbar (bool, optional) – Whether to show a progress bar.