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

oset

An ordered set which stores elements as the keys of dict (ordered as of

BeliefPropagationCommon

Common interfaces for belief propagation algorithms.

D1BP

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

Functions

array_contract(arrays, inputs[, output, optimize, backend])

combine_local_contractions(tvals, mvals, backend[, ...])

compute_all_tensor_messages_tree(x, ms[, backend])

Given set of messages ms incident to tensor with data x, compute

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.array_contract(arrays, inputs, output=None, optimize=None, backend=None, **kwargs)
class quimb.experimental.belief_propagation.d1bp.oset(it=())

An ordered set which stores elements as the keys of dict (ordered as of python 3.6). ‘A few times’ slower than using a set directly for small sizes, but makes everything deterministic.

__slots__ = ('_d',)
classmethod _from_dict(d)
classmethod from_dict(d)

Public method makes sure to copy incoming dictionary.

copy()
__deepcopy__(memo)
add(k)
discard(k)
remove(k)
clear()
update(*others)
union(*others)
intersection_update(*others)
intersection(*others)
difference_update(*others)
difference(*others)
popleft()
popright()
pop
__eq__(other)

Return self==value.

__or__(other)
__ior__(other)
__and__(other)
__iand__(other)
__sub__(other)
__isub__(other)
__len__()
__iter__()
__contains__(x)
__repr__()

Return repr(self).

class quimb.experimental.belief_propagation.d1bp.BeliefPropagationCommon

Common interfaces for belief propagation algorithms.

Parameters:
  • max_iterations (int, optional) – The maximum number of iterations to perform.

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

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

run(max_iterations=1000, tol=5e-06, info=None, progbar=False)
quimb.experimental.belief_propagation.d1bp.combine_local_contractions(tvals, mvals, backend, strip_exponent=False, check_for_zero=True)
quimb.experimental.belief_propagation.d1bp.compute_all_tensor_messages_tree(x, ms, backend=None)

Given set of messages ms incident to tensor with data x, compute the corresponding next output messages, using the ‘tree’ implementation.

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)]

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.