-
Notifications
You must be signed in to change notification settings - Fork 5
Fixed send message computations in Schafer-Shenoy #15
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
Open
dar326
wants to merge
6
commits into
master
Choose a base branch
from
send_message_fixes2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
11ac47c
Fixed send message computations in Schafer-Shenoy
dar326 efd3757
adding identity element
dar326 09427f0
Delete computation.py
dar326 325dcfb
Delete sum_product.py
dar326 f7d8198
Adding computation.py and sum_product.py
dar326 b92e566
direct implementation of Shafer-Shenoy updates
dar326 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this special case
1related only to the normal sum-product? If some other distributive law was used, would the value be different then? If so, should this if-else be inside the specific "sum-product distributive law" so it wouldn't affect all distributive laws? Or, alternatively, should each distributive law define an identity element ("empty value") that is used in this kind of cases? My gut feeling is that this latter option would make perfect sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, now that this if-else is only here, it won't fix all other places where
dl.einsumis used. I suppose this special-case handling should be used always whendl.einsumis used, right? Therefore, even more so, I would suggest defining an identity element for the distributive laws.Does this make sense or am I misunderstanding something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been trying to come up with a simple unit test for the inconsistent results that were identified in the original issue. However, the issue derives from the lack of a guaranteed order when creating Python sets. There is an assumption about the ordering of the indices within the
remove_messagesfunction implementation with regard to the ordering of the indices. The use of thesetfunction prior to callingremove_messagesproduces inconsistent behavior. So, the incorrect results are only produced occasionally.There are 2 possible fixes:
Use NumPy's set functions in place of the standard Python
setfunction so that the indices are always ordered prior to being used as an argument toremove_message.Rely on
numpy.einsumto compute the product of the messages with the message from the current neighbor being excluded. I originally wrote theremove_messagefunction in order to avoid repeated calculations of the product of the messages. But the complexity of the code for performing the calculation to divide out the neighbor's message may not be worth any small efficiency gains from avoiding the repeated calculations.My commit included both replacing the standard
setfunction calls with NumPy set implementations and removing theremove_messagefunction to simply the code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an additional commit in this branch to support an identity element for SumProduct distributive law
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! If it's not easy to add a unit test, then that can be left out. 👍
Your most recent commit added new files
computation.pyandsum_product.pythat are in the root of the repository, not insidejunctiontreepackage. I suppose this was a mistake, right? Being outside the package, they aren't used anywhere. Perhaps you meant to replacejunctiontree/computation.pyandjunctiontree/sum_product.py?