quimb.tensor.belief_propagation.l2bp¶
Classes¶
Lazy (as in multiple uncontracted tensors per site) 2-norm (as in for |
Functions¶
|
|
|
Estimate the norm squared of |
|
Compress |
Module Contents¶
- quimb.tensor.belief_propagation.l2bp._identity(x)¶
- class quimb.tensor.belief_propagation.l2bp.L2BP(tn, site_tags=None, *, damping=0.0, diis=False, update='sequential', sweep_order='auto', normalize=None, distance=None, symmetrize=True, local_convergence=True, optimize='auto-hq', contract_every=None, inplace=False, **contract_opts)¶
Bases:
quimb.tensor.belief_propagation.bp_common.BeliefPropagationCommonLazy (as in multiple uncontracted tensors per site) 2-norm (as in for wavefunctions and operators) belief propagation.
- Parameters:
tn (TensorNetwork) – The tensor network to form the 2-norm of and run BP on.
site_tags (sequence of str, optional) – Tags for sites in
tn. Each tag should select a region, and regions must not overlap. Infer tags for structured networks.damping (float or callable, optional) – Mix old and new messages as
damping * old + (1 - damping) * new. This can make convergence more reliable but slower.diis (bool or dict, optional) – Use direct inversion in the iterative subspace (DIIS) to estimate messages with lower error. A dict can contain DIIS options:
max_history,beta,rcond.update ({'sequential', 'parallel'}, optional) – With ‘sequential’, use new messages in later updates of the same sweep. With ‘parallel’, use only messages from the previous sweep. Sequential updates usually help convergence. Parallel updates can converge to different solutions.
sweep_order ({'auto', 'alternate', 'fixed', None}, optional) – Sequential update order. Use ‘alternate’ to reverse each sweep, starting reversed, or ‘fixed’ to keep the same order. With ‘auto’, alternate on graphs with no loops, else use a fixed order. With None, use reverse insertion order. See
SweepScheduler.normalize ({'L1', 'L2', 'L2phased', 'Linf', callable}, optional) – Norm to use after each update. With None, choose automatically. Callables should take a message and return its normalized form. ‘L2phased’ also normalizes the phase, and is the default for complex dtypes.
distance ({'L1', 'L2', 'L2phased', 'Linf', 'cosine', callable}, optional) – Distance between messages to check convergence. With None, choose automatically. Callables should take two messages and return their distance. ‘L2phased’ normalizes their phases before computing the L2 distance. It is the default for complex dtypes when normalization does not already fix the phase.
symmetrize (bool or callable, optional) – Whether to symmetrize the messages, i.e. for each message ensure that it is hermitian with respect to its bra and ket indices. If a callable it should take a message and return the symmetrized message.
local_convergence (bool, optional) – Stop updating messages whose input messages have converged.
optimize (str or PathOptimizer, optional) – The path optimizer to use when contracting the messages.
contract_every (int, optional) – If not None, ‘contract’ (via BP) the tensor network every
contract_everyiterations. The resulting values are stored inzvalsat corresponding pointszval_its.inplace (bool, optional) – Whether to perform any operations inplace on the input tensor network.
contract_opts – Other options supplied to
cotengra.array_contract.
- local_convergence = True¶
- optimize = 'auto-hq'¶
- contract_opts¶
- sweeper¶
- property symmetrize¶
- messages¶
- contraction_tns¶
- 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,
}
- normalize_message_pairs()¶
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). This is different to normalizing each message.
- contract(strip_exponent=False, check_zero=True, **kwargs)¶
Contract the frobenius norm squared of the target tensor network via lazy belief propagation using the current messages.
- partial_trace(site, normalized=True, optimize='auto-hq')¶
- compress(tn, max_bond=None, cutoff=5e-06, cutoff_mode='rsum2', renorm=0, lazy=False, reduce_opts=None, compress_opts=None, **kwargs)¶
Compress the state
tn, assumed to matched this L2BP instance, using the messages stored.
- quimb.tensor.belief_propagation.l2bp.contract_l2bp(tn, site_tags=None, damping=0.0, update='sequential', local_convergence=True, optimize='auto-hq', max_iterations=1000, tol=5e-06, strip_exponent=False, info=None, progbar=False, **contract_opts)¶
Estimate the norm squared of
tnusing lazy belief propagation.- Parameters:
tn (TensorNetwork) – The tensor network to estimate the norm squared of.
site_tags (sequence of str, optional) – The tags identifying the sites in
tn, each tag forms a region.damping (float, optional) – The damping parameter to use, defaults to no damping.
update ({'parallel', 'sequential'}, optional) – Whether to update all messages in parallel or sequentially.
local_convergence (bool, optional) – Stop updating messages whose input messages have converged.
optimize (str or PathOptimizer, optional) – The contraction strategy to use.
max_iterations (int, optional) – The maximum number of iterations to perform.
tol (float, optional) – The convergence tolerance for messages.
strip_exponent (bool, optional) – Whether to strip the exponent from the final result. If
Truethen 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.
contract_opts – Other options supplied to
cotengra.array_contract.
- quimb.tensor.belief_propagation.l2bp.compress_l2bp(tn, max_bond, cutoff=0.0, cutoff_mode='rsum2', max_iterations=1000, tol=5e-06, site_tags=None, damping=0.0, update='sequential', local_convergence=True, optimize='auto-hq', lazy=False, inplace=False, info=None, progbar=False, **contract_opts)¶
Compress
tnusing lazy belief propagation, producing a tensor network with a single tensor per site.- Parameters:
tn (TensorNetwork) – The tensor network to form the 2-norm of, run BP on and then compress.
max_bond (int) – The maximum bond dimension to compress to.
cutoff (float, optional) – The cutoff to use when compressing.
cutoff_mode (int, optional) – The cutoff mode to use when compressing.
max_iterations (int, optional) – The maximum number of iterations to perform.
tol (float, optional) – The convergence tolerance for messages.
site_tags (sequence of str, optional) – The tags identifying the sites in
tn, each tag forms a region. If the tensor network is structured, then these are inferred automatically.damping (float, optional) – The damping parameter to use, defaults to no damping.
update ({'parallel', 'sequential'}, optional) – Whether to update all messages in parallel or sequentially.
local_convergence (bool, optional) – Stop updating messages whose input messages have converged.
optimize (str or PathOptimizer, optional) – The path optimizer to use when contracting the messages.
lazy (bool, optional) – Whether to perform the compression lazily, i.e. to leave the computed compression projectors uncontracted.
inplace (bool, optional) – Whether to perform the compression inplace.
info (dict, optional) – If specified, update this dictionary with information about the belief propagation run.
progbar (bool, optional) – Whether to show a progress bar.
contract_opts – Other options supplied to
cotengra.array_contract.
- Return type: