Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for BP edge case where network evaluates to 0 #178

Merged
merged 4 commits into from
May 14, 2024

Conversation

JoeyT1994
Copy link
Contributor

@JoeyT1994 JoeyT1994 commented May 14, 2024

This PR fixed the bp edge case where the network contracts to the scalar 0 which would previously yield Nan.

This is achieved by:

  1. Updating the default_message_update function to only divide by the norm if its not zero -> avoiding the creating of message tensors with nan in them.
  2. Adding to logscalar(alg::Algorithm"bp", tn::AbstractITensorNetwork) a check if any of the denominators terms are zero. If this is the case then log(tn) should be -Inf. This is because, on a tree, if the product of message(pe) and message(reverse(pe) on any partitionedge is zero then the contraction of the tree must be zero (assuming the messages are converged).

A quick test is added.

@ryanlevy this should fix the issue with bp in ITensorNumericalAnalysis.jl

src/contract.jl Outdated Show resolved Hide resolved
src/contract.jl Outdated Show resolved Hide resolved
@mtfishman mtfishman merged commit 43ff72e into ITensor:main May 14, 2024
5 of 6 checks passed
@JoeyT1994 JoeyT1994 deleted the fix_bp_edgecases branch June 16, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants