quimb.tensor.belief_propagation.l1bp ==================================== .. py:module:: quimb.tensor.belief_propagation.l1bp Classes ------- .. autoapisummary:: quimb.tensor.belief_propagation.l1bp.L1BP Functions --------- .. autoapisummary:: quimb.tensor.belief_propagation.l1bp.contract_l1bp Module Contents --------------- .. py:class:: L1BP(tn, site_tags=None, *, damping=0.0, diis=False, update='sequential', normalize=None, distance=None, local_convergence=True, optimize='auto-hq', message_init_function=None, contract_every=None, inplace=False, **contract_opts) Bases: :py:obj:`quimb.tensor.belief_propagation.bp_common.BeliefPropagationCommon` Lazy 1-norm belief propagation. BP is run between groups of tensors defined by ``site_tags``. The message updates are lazy contractions. :param tn: The tensor network to run BP on. :type tn: TensorNetwork :param site_tags: The tags identifying the sites in ``tn``, each tag forms a region, which should not overlap. If the tensor network is structured, then these are inferred automatically. :type site_tags: sequence of str, optional :param damping: The damping factor to apply to messages. This simply mixes some part of the old message into the new one, with the final message being ``damping * old + (1 - damping) * new``. This makes convergence more reliable but slower. :type damping: float or callable, optional :param diis: Whether to use direct inversion in the iterative subspace to help converge the messages by extrapolating to low error guesses. If a dict, should contain options for the DIIS algorithm. The relevant options are {`max_history`, `beta`, `rcond`}. :type diis: bool or dict, optional :param update: Whether to update messages sequentially (newly computed messages are immediately used for other updates in the same iteration round) or in parallel (all messages are comptued using messages from the previous round only). Sequential generally helps convergence but parallel can possibly converge to differnt solutions. :type update: {'sequential', 'parallel'}, optional :param normalize: How to normalize messages after each update. If None choose automatically. If a callable, it should take a message and return the normalized message. If a string, it should be one of 'L1', 'L2', 'L2phased', 'Linf' for the corresponding norms. 'L2phased' is like 'L2' but also normalizes the phase of the message, by default used for complex dtypes. :type normalize: {'L1', 'L2', 'L2phased', 'Linf', callable}, optional :param distance: How to compute the distance between messages to check for convergence. If None choose automatically. If a callable, it should take two messages and return the distance. If a string, it should be one of 'L1', 'L2', 'L2phased', 'Linf', or 'cosine' for the corresponding norms. 'L2phased' is like 'L2' but also normalizes the phases of the messages, by default used for complex dtypes if phased normalization is not already being used. :type distance: {'L1', 'L2', 'L2phased', 'Linf', 'cosine', callable}, optional :param local_convergence: Whether to allow messages to locally converge - i.e. if all their input messages have converged then stop updating them. :type local_convergence: bool, optional :param optimize: The path optimizer to use when contracting the messages. :type optimize: str or PathOptimizer, optional :param contract_every: If not None, 'contract' (via BP) the tensor network every ``contract_every`` iterations. The resulting values are stored in ``zvals`` at corresponding points ``zval_its``. :type contract_every: int, optional :param inplace: Whether to perform any operations inplace on the input tensor network. :type inplace: bool, optional :param contract_opts: Other options supplied to ``cotengra.array_contract``. .. py:attribute:: local_convergence :value: True .. py:attribute:: optimize :value: 'auto-hq' .. py:attribute:: contract_opts .. py:attribute:: touched .. py:attribute:: messages .. py:attribute:: contraction_tns .. py:method:: iterate(tol=5e-06) Perform one round of message passing. .. py:method:: contract(strip_exponent=False, check_zero=True, **kwargs) Contract the target tensor network via lazy belief propagation using the current messages. .. py:method:: normalize_message_pairs() Normalize all messages such that for each bond ` = 1` and ` = ` (but in general != 1). .. py:function:: contract_l1bp(tn, max_iterations=1000, tol=5e-06, site_tags=None, damping=0.0, update='sequential', diis=False, local_convergence=True, optimize='auto-hq', strip_exponent=False, info=None, progbar=False, **contract_opts) Estimate the contraction of ``tn`` using lazy 1-norm belief propagation. :param tn: The tensor network to contract. :type tn: TensorNetwork :param max_iterations: The maximum number of iterations to perform. :type max_iterations: int, optional :param tol: The convergence tolerance for messages. :type tol: float, optional :param site_tags: The tags identifying the sites in ``tn``, each tag forms a region. If the tensor network is structured, then these are inferred automatically. :type site_tags: sequence of str, optional :param damping: The damping parameter to use, defaults to no damping. :type damping: float, optional :param update: Whether to update all messages in parallel or sequentially. :type update: {'parallel', 'sequential'}, optional :param local_convergence: Whether to allow messages to locally converge - i.e. if all their input messages have converged then stop updating them. :type local_convergence: bool, optional :param optimize: The path optimizer to use when contracting the messages. :type optimize: str or PathOptimizer, optional :param progbar: Whether to show a progress bar. :type progbar: bool, optional :param strip_exponent: Whether to strip the exponent from the final result. If ``True`` then the returned result is ``(mantissa, exponent)``. :type strip_exponent: bool, optional :param info: If specified, update this dictionary with information about the belief propagation run. :type info: dict, optional :param contract_opts: Other options supplied to ``cotengra.array_contract``.