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

Fix BP convergence metric for complex networks #193

Merged
merged 9 commits into from
Jun 25, 2024

Conversation

JoeyT1994
Copy link
Contributor

This PR alters the message_diff function in BP to do a better convergence test.

Specifically, it defines it as 1 - |<m_{e, t+1}|m_{e, t}>|^{2} where |m_{e, t}> is the message tensor (reshaped as a vector) on edge e at iteration t and |m_{e, t}> is the message tensor (reshaped as a vector) on edge e at the subsequent iteration.

It is analogous to the infidelity measure for a quantum wavefunction and a strict lower bound on the trace distance,
i.e. 1 - |<m_{e, t+1}|m_{e, t}>|^{2} <= 0.5*Tr(|m_{e, t}><m_{e, t}| - |m_{e, t+1}><m_{e, t+1}|)

Importantly, it is independent of a "phase" factor e^i\theta difference between the two messages, something which I believe the Euclidean distance isn't and therefore would run into trouble with complex numbers.

@mtfishman
Copy link
Member

mtfishman commented Jun 25, 2024

Good point about the Euclidean distance, I think the Euclidean distance would be something like 1 - real(dot(lhs / norm(lhs), rhs / norm(rhs))) which as you say would not be invariant under multiplying lhs or rhs by a phase factor.

@mtfishman
Copy link
Member

For some terminology, this measure is related to the cosine similarity, and the cosine distance which is defined in Distances.jl, but only for real numbers so far.

@mtfishman mtfishman changed the title Bp convergence test BP convergence test Jun 25, 2024
@mtfishman mtfishman changed the title BP convergence test Fix BP convergence metric for complex networks Jun 25, 2024
@mtfishman mtfishman merged commit dec464f into ITensor:main Jun 25, 2024
5 of 6 checks passed
@mtfishman
Copy link
Member

Thanks! Nice to see the BP code getting more robust.

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