Skip to content

Commit

Permalink
Fix index-out-of-bounds issue in LinkPredNDCG(weighted=True) (#9963)
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s authored Jan 21, 2025
1 parent 9c73f99 commit 47ac818
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torch_geometric/metrics/link_pred.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def _compute(self, data: LinkPredMetricData) -> Tensor:
self.discount,
self.discount.new_full((1, ), fill_value=float('inf')),
])
discount = discount[pos.clamp(max=self.k + 1)]
discount = discount[pos.clamp(max=self.k)]

idcg = scatter( # Apply discount and aggregate:
data.edge_label_weight / discount,
Expand Down

0 comments on commit 47ac818

Please sign in to comment.