-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
Good point about the Euclidean distance, I think the Euclidean distance would be something like |
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. |
Co-authored-by: Matt Fishman <[email protected]>
Thanks! Nice to see the BP code getting more robust. |
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 iterationt
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.