Fix missing hyperedge weight application in HypergraphConv#10600
Open
Mr-Neutr0n wants to merge 2 commits intopyg-team:masterfrom
Open
Fix missing hyperedge weight application in HypergraphConv#10600Mr-Neutr0n wants to merge 2 commits intopyg-team:masterfrom
Mr-Neutr0n wants to merge 2 commits intopyg-team:masterfrom
Conversation
The documented formula for HypergraphConv is:
X' = D^{-1} H W B^{-1} H^T X Theta
where W is the diagonal hyperedge weight matrix. However, the
implementation only used hyperedge_weight to compute the node degree
matrix D, but never actually applied W to scale the intermediate edge
representations between the two message passing steps.
This meant that passing non-uniform hyperedge_weight had only a partial
effect (via D normalization) rather than the full effect described by
the formula. The fix applies W to the edge features after the first
propagation (node-to-edge) and before the second (edge-to-node),
correctly implementing D^{-1} H W B^{-1} H^T X Theta.
When hyperedge_weight is all ones (the default), behavior is unchanged.
for more information, see https://pre-commit.ci
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
HypergraphConvdocuments the formulaX' = D^{-1} H W B^{-1} H^T X Theta, whereWis the diagonal hyperedge weight matrix. However,hyperedge_weightwas only used to compute the node degree matrixD-- the weight matrixWitself was never applied to scale the intermediate edge representations between the two message passing steps.This meant that providing non-uniform
hyperedge_weighthad an incomplete effect: it influenced the degree-based normalization (D) but did not scale the edge features as the formula requires. This fix appliesWto the edge features after the node-to-edge aggregation and before the edge-to-node aggregation, correctly implementing the full formula.When
hyperedge_weightis all ones (the default), behavior is unchanged.Changes
torch_geometric/nn/conv/hypergraph_conv.py: Applyhyperedge_weightto intermediate edge representation between the twopropagatecalls, with correct reshaping for both attention and non-attention modes.test/nn/conv/test_hypergraph_conv.py: Add test verifying that uniform weights match default behavior, and non-uniform weights produce different (correct) results.Test plan
torch.allclose)