pyg-nightly 2.7.0.dev20250212__py3-none-any.whl → 2.7.0.dev20250214__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- {pyg_nightly-2.7.0.dev20250212.dist-info → pyg_nightly-2.7.0.dev20250214.dist-info}/METADATA +1 -1
- {pyg_nightly-2.7.0.dev20250212.dist-info → pyg_nightly-2.7.0.dev20250214.dist-info}/RECORD +6 -6
- torch_geometric/__init__.py +1 -1
- torch_geometric/metrics/__init__.py +2 -0
- torch_geometric/metrics/link_pred.py +53 -6
- {pyg_nightly-2.7.0.dev20250212.dist-info → pyg_nightly-2.7.0.dev20250214.dist-info}/WHEEL +0 -0
{pyg_nightly-2.7.0.dev20250212.dist-info → pyg_nightly-2.7.0.dev20250214.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: pyg-nightly
|
3
|
-
Version: 2.7.0.
|
3
|
+
Version: 2.7.0.dev20250214
|
4
4
|
Summary: Graph Neural Network Library for PyTorch
|
5
5
|
Keywords: deep-learning,pytorch,geometric-deep-learning,graph-neural-networks,graph-convolutional-networks
|
6
6
|
Author-email: Matthias Fey <matthias@pyg.org>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
torch_geometric/__init__.py,sha256=
|
1
|
+
torch_geometric/__init__.py,sha256=wEIwjfiE7YtSKe1hUelXwhBp2yBtwx2u2gRooK6Gb_s,1904
|
2
2
|
torch_geometric/_compile.py,sha256=f-WQeH4VLi5Hn9lrgztFUCSrN_FImjhQa6BxFzcYC38,1338
|
3
3
|
torch_geometric/_onnx.py,sha256=V9ffrIKSqhDw6xUZ12lkuSfNs48cQp2EeJ6Z19GfnVw,349
|
4
4
|
torch_geometric/backend.py,sha256=lVaf7aLoVaB3M-UcByUJ1G4T4FOK6LXAg0CF4W3E8jo,1575
|
@@ -288,8 +288,8 @@ torch_geometric/loader/shadow.py,sha256=_hCspYf9SlJYX0lqEjxFec9e9t1iMScNThOoWR1w
|
|
288
288
|
torch_geometric/loader/temporal_dataloader.py,sha256=AQ2QFeiXKbPp6I8sUeE8H7br-1_yndivXt7Z6_w62zI,2248
|
289
289
|
torch_geometric/loader/utils.py,sha256=f27mczQ7fEP2HpTsJGJxKS0slPu0j8zTba3jP8ViNck,14901
|
290
290
|
torch_geometric/loader/zip_loader.py,sha256=3lt10fD15Rxm1WhWzypswGzCEwUz4h8OLCD1nE15yNg,3843
|
291
|
-
torch_geometric/metrics/__init__.py,sha256=
|
292
|
-
torch_geometric/metrics/link_pred.py,sha256=
|
291
|
+
torch_geometric/metrics/__init__.py,sha256=3krvDobW6vV5yHTjq2S2pmOXxNfysNG26muq7z48e94,699
|
292
|
+
torch_geometric/metrics/link_pred.py,sha256=cz9GbvZthV2PAnVnxiZlksGr0VmTQOJGNuZ-OYYg04U,29667
|
293
293
|
torch_geometric/nn/__init__.py,sha256=RrWRzEoqtR3lsO2lAzYXboLPb3uYEX2z3tLxiBIVWjc,847
|
294
294
|
torch_geometric/nn/data_parallel.py,sha256=lDAxRi83UNuzAQSj3eu9K2sQheOIU6wqR5elS6oDs90,4764
|
295
295
|
torch_geometric/nn/encoding.py,sha256=QNjwWczYExZ1wRGBmpuqYbn6tB7NC4BU-DEgzjhcZqw,3115
|
@@ -630,6 +630,6 @@ torch_geometric/utils/undirected.py,sha256=H_nfpI0_WluOG6VfjPyldvcjL4w5USAKWu2x5
|
|
630
630
|
torch_geometric/visualization/__init__.py,sha256=PyR_4K5SafsJrBr6qWrkjKr6GBL1b7FtZybyXCDEVwY,154
|
631
631
|
torch_geometric/visualization/graph.py,sha256=ZuLPL92yGRi7lxlqsUPwL_EVVXF7P2kMcveTtW79vpA,4784
|
632
632
|
torch_geometric/visualization/influence.py,sha256=CWMvuNA_Nf1sfbJmQgn58yS4OFpeKXeZPe7kEuvkUBw,477
|
633
|
-
pyg_nightly-2.7.0.
|
634
|
-
pyg_nightly-2.7.0.
|
635
|
-
pyg_nightly-2.7.0.
|
633
|
+
pyg_nightly-2.7.0.dev20250214.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
634
|
+
pyg_nightly-2.7.0.dev20250214.dist-info/METADATA,sha256=7oAMP5u6qz3XuWwE8lms2zjkk_lGmt3Q7-3FswFCbUk,62977
|
635
|
+
pyg_nightly-2.7.0.dev20250214.dist-info/RECORD,,
|
torch_geometric/__init__.py
CHANGED
@@ -30,7 +30,7 @@ from .lazy_loader import LazyLoader
|
|
30
30
|
contrib = LazyLoader('contrib', globals(), 'torch_geometric.contrib')
|
31
31
|
graphgym = LazyLoader('graphgym', globals(), 'torch_geometric.graphgym')
|
32
32
|
|
33
|
-
__version__ = '2.7.0.
|
33
|
+
__version__ = '2.7.0.dev20250214'
|
34
34
|
|
35
35
|
__all__ = [
|
36
36
|
'Index',
|
@@ -13,6 +13,7 @@ from .link_pred import (
|
|
13
13
|
LinkPredCoverage,
|
14
14
|
LinkPredDiversity,
|
15
15
|
LinkPredPersonalization,
|
16
|
+
LinkPredAveragePopularity,
|
16
17
|
)
|
17
18
|
|
18
19
|
link_pred_metrics = [
|
@@ -28,6 +29,7 @@ link_pred_metrics = [
|
|
28
29
|
'LinkPredCoverage',
|
29
30
|
'LinkPredDiversity',
|
30
31
|
'LinkPredPersonalization',
|
32
|
+
'LinkPredAveragePopularity',
|
31
33
|
]
|
32
34
|
|
33
35
|
__all__ = link_pred_metrics
|
@@ -402,11 +402,8 @@ class LinkPredMetricCollection(torch.nn.ModuleDict):
|
|
402
402
|
|
403
403
|
for metric in self.values():
|
404
404
|
if not isinstance(metric, LinkPredMetric):
|
405
|
-
metric.update(
|
406
|
-
|
407
|
-
edge_label_index=edge_label_index,
|
408
|
-
edge_label_weight=edge_label_weight,
|
409
|
-
)
|
405
|
+
metric.update(pred_index_mat, edge_label_index,
|
406
|
+
edge_label_weight)
|
410
407
|
|
411
408
|
def compute(self) -> Dict[str, Tensor]:
|
412
409
|
r"""Computes the final metric values."""
|
@@ -722,12 +719,14 @@ class LinkPredPersonalization(_LinkPredMetric):
|
|
722
719
|
of user recommendations should be processed at once.
|
723
720
|
(default: :obj:`2**16`)
|
724
721
|
"""
|
722
|
+
higher_is_better: bool = True
|
723
|
+
|
725
724
|
def __init__(self, k: int, batch_size: int = 2**16) -> None:
|
726
725
|
super().__init__(k)
|
727
726
|
self.batch_size = batch_size
|
728
727
|
|
729
728
|
if WITH_TORCHMETRICS:
|
730
|
-
self.add_state(
|
729
|
+
self.add_state('preds', default=[], dist_reduce_fx='cat')
|
731
730
|
self.add_state('dev_tensor', torch.empty(0), dist_reduce_fx='sum')
|
732
731
|
else:
|
733
732
|
self.preds: List[Tensor] = []
|
@@ -787,3 +786,51 @@ class LinkPredPersonalization(_LinkPredMetric):
|
|
787
786
|
|
788
787
|
def _reset(self) -> None:
|
789
788
|
self.preds = []
|
789
|
+
|
790
|
+
|
791
|
+
class LinkPredAveragePopularity(_LinkPredMetric):
|
792
|
+
r"""A link prediction metric to compute the Average Recommendation
|
793
|
+
Popularity (ARP) @ :math:`k`, which provides insights into the model's
|
794
|
+
tendency to recommend popular items by averaging the popularity scores of
|
795
|
+
items within the top-:math:`k` recommendations.
|
796
|
+
|
797
|
+
Args:
|
798
|
+
k (int): The number of top-:math:`k` predictions to evaluate against.
|
799
|
+
popularity (torch.Tensor): The popularity of every item in the training
|
800
|
+
set, *e.g.*, the number of times an item has been rated.
|
801
|
+
"""
|
802
|
+
higher_is_better: bool = False
|
803
|
+
|
804
|
+
def __init__(self, k: int, popularity: Tensor) -> None:
|
805
|
+
super().__init__(k)
|
806
|
+
|
807
|
+
if WITH_TORCHMETRICS:
|
808
|
+
self.add_state('accum', torch.tensor(0.), dist_reduce_fx='sum')
|
809
|
+
self.add_state('total', torch.tensor(0), dist_reduce_fx='sum')
|
810
|
+
else:
|
811
|
+
self.register_buffer('accum', torch.tensor(0.))
|
812
|
+
self.register_buffer('total', torch.tensor(0))
|
813
|
+
|
814
|
+
self.popularity: Tensor
|
815
|
+
self.register_buffer('popularity', popularity)
|
816
|
+
|
817
|
+
def update(
|
818
|
+
self,
|
819
|
+
pred_index_mat: Tensor,
|
820
|
+
edge_label_index: Union[Tensor, Tuple[Tensor, Tensor]],
|
821
|
+
edge_label_weight: Optional[Tensor] = None,
|
822
|
+
) -> None:
|
823
|
+
pred_index_mat = pred_index_mat[:, :self.k]
|
824
|
+
popularity = self.popularity[pred_index_mat]
|
825
|
+
popularity = popularity.to(self.accum.dtype).mean(dim=-1)
|
826
|
+
self.accum += popularity.sum()
|
827
|
+
self.total += popularity.numel()
|
828
|
+
|
829
|
+
def compute(self) -> Tensor:
|
830
|
+
if self.total == 0:
|
831
|
+
return torch.zeros_like(self.accum)
|
832
|
+
return self.accum / self.total
|
833
|
+
|
834
|
+
def _reset(self) -> None:
|
835
|
+
self.accum.zero_()
|
836
|
+
self.total.zero_()
|
File without changes
|