Fix bugs in PNAConv
and DegreeScalerAggregation
#6609
Merged
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.
Some fixes, including bugs fixes and minor documentation fixes
torch_geometric/nn/aggr/scaler.py
The
deg
tensor should be clamped during theinverse_linear
computation and thus avoid division by zero (in case thedeg
tensor contains a zero degree value). Previous implementation will make the zero degree value equal to two in theamplification
andattenuation
cases where we also add one directly. Though I am not sure whether this way is correct and whether we also need toclamp(1)
in thelinear
scaler.torch_geometric/nn/conv/pna_conv.py
The previous implementation utilized two for loops to compute the
deg_histogram
tensor. The first loop calculates themax_degree
, while the second loop updates thedeg_histogram
by adding eachbincount
, with aminlength
ofmax_degree + 1
. However, for certain loaders (e.g. theNeighborLoader
), the degree in the second loop may exceed themax_degree
computed in the first loop and thus raise following error. Also, current implementation that replaces the two loops with one loop may potentially improve computation speed, although I don't verify this...