pyg-nightly 2.7.0.dev20250904__py3-none-any.whl → 2.7.0.dev20250905__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyg_nightly-2.7.0.dev20250904.dist-info → pyg_nightly-2.7.0.dev20250905.dist-info}/METADATA +1 -1
- {pyg_nightly-2.7.0.dev20250904.dist-info → pyg_nightly-2.7.0.dev20250905.dist-info}/RECORD +7 -7
- torch_geometric/__init__.py +1 -1
- torch_geometric/metrics/link_pred.py +13 -2
- torch_geometric/utils/cross_entropy.py +34 -13
- {pyg_nightly-2.7.0.dev20250904.dist-info → pyg_nightly-2.7.0.dev20250905.dist-info}/WHEEL +0 -0
- {pyg_nightly-2.7.0.dev20250904.dist-info → pyg_nightly-2.7.0.dev20250905.dist-info}/licenses/LICENSE +0 -0
{pyg_nightly-2.7.0.dev20250904.dist-info → pyg_nightly-2.7.0.dev20250905.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pyg-nightly
|
3
|
-
Version: 2.7.0.
|
3
|
+
Version: 2.7.0.dev20250905
|
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=JaI2udwlYGKK9_OGrMEQn05CBfOSEPFFsk9OtBnPN2c,2292
|
2
2
|
torch_geometric/_compile.py,sha256=9yqMTBKatZPr40WavJz9FjNi7pQj8YZAZOyZmmRGXgc,1351
|
3
3
|
torch_geometric/_onnx.py,sha256=ODB_8cwFUiwBUjngXn6-K5HHb7IDul7DDXuuGX7vj_0,8178
|
4
4
|
torch_geometric/backend.py,sha256=lVaf7aLoVaB3M-UcByUJ1G4T4FOK6LXAg0CF4W3E8jo,1575
|
@@ -294,7 +294,7 @@ torch_geometric/loader/temporal_dataloader.py,sha256=Z7L_rYdl6SYBQXAgtr18FVcmfMH
|
|
294
294
|
torch_geometric/loader/utils.py,sha256=3hzKzIgB52QIZu7Jdn4JeXZaegIJinIQfIUP9DrUWUQ,14903
|
295
295
|
torch_geometric/loader/zip_loader.py,sha256=3lt10fD15Rxm1WhWzypswGzCEwUz4h8OLCD1nE15yNg,3843
|
296
296
|
torch_geometric/metrics/__init__.py,sha256=3krvDobW6vV5yHTjq2S2pmOXxNfysNG26muq7z48e94,699
|
297
|
-
torch_geometric/metrics/link_pred.py,sha256=
|
297
|
+
torch_geometric/metrics/link_pred.py,sha256=1_hE3KiRqAdZLI6QuUbjgyFC__mTyFu_RimM3bD8wRw,31678
|
298
298
|
torch_geometric/nn/__init__.py,sha256=kQHHHUxFDht2ztD-XFQuv98TvC8MdodaFsIjAvltJBw,874
|
299
299
|
torch_geometric/nn/data_parallel.py,sha256=YiybTWoSFyfSzlXAamZ_-y1f7B6tvDEFHOuy_AyJz9Q,4761
|
300
300
|
torch_geometric/nn/encoding.py,sha256=3DCOCO-XFt-lMb97sHWGN-4KeGUFY5lVo9P00SzrCNk,3559
|
@@ -620,7 +620,7 @@ torch_geometric/utils/_trim_to_layer.py,sha256=cauOEzMJJK4w9BC-Pg1bHVncBYqG9XxQe
|
|
620
620
|
torch_geometric/utils/_unbatch.py,sha256=B0vjKI96PtHvSBG8F_lqvsiJE134aVjUurPZsG6UZRI,2378
|
621
621
|
torch_geometric/utils/augmentation.py,sha256=1F0YCuaklZ9ZbXxdFV0oOoemWvLd8p60WvFo2chzl7E,8600
|
622
622
|
torch_geometric/utils/convert.py,sha256=RE5n5no74Xu39-QMWFE0-1RvTgykdK33ymyjF9WcuSs,21938
|
623
|
-
torch_geometric/utils/cross_entropy.py,sha256=
|
623
|
+
torch_geometric/utils/cross_entropy.py,sha256=_6whuSCWKNzavOLf83uZbI9RFU0wGRHQict_4-8XIYs,3773
|
624
624
|
torch_geometric/utils/dropout.py,sha256=gg0rDnD4FLvBaKSoLAkZwViAQflhLefJm6_Mju5dmQs,11416
|
625
625
|
torch_geometric/utils/embedding.py,sha256=Ac_MPSrZGpw-e-gU6Yz-seUioC2WZxBSSzXFeclGwMk,5232
|
626
626
|
torch_geometric/utils/functions.py,sha256=orQdS_6EpzWSmBHSok3WhxCzLy9neB-cin1aTnlXY-8,703
|
@@ -646,7 +646,7 @@ torch_geometric/utils/undirected.py,sha256=H_nfpI0_WluOG6VfjPyldvcjL4w5USAKWu2x5
|
|
646
646
|
torch_geometric/visualization/__init__.py,sha256=b-HnVesXjyJ_L1N-DnjiRiRVf7lhwKaBQF_2i5YMVSU,208
|
647
647
|
torch_geometric/visualization/graph.py,sha256=mfZHXYfiU-CWMtfawYc80IxVwVmtK9hbIkSKhM_j7oI,14311
|
648
648
|
torch_geometric/visualization/influence.py,sha256=CWMvuNA_Nf1sfbJmQgn58yS4OFpeKXeZPe7kEuvkUBw,477
|
649
|
-
pyg_nightly-2.7.0.
|
650
|
-
pyg_nightly-2.7.0.
|
651
|
-
pyg_nightly-2.7.0.
|
652
|
-
pyg_nightly-2.7.0.
|
649
|
+
pyg_nightly-2.7.0.dev20250905.dist-info/licenses/LICENSE,sha256=ic-27cMJc1kWoMEYncz3Ya3Ur2Bi3bNLWib2DT763-o,1067
|
650
|
+
pyg_nightly-2.7.0.dev20250905.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
651
|
+
pyg_nightly-2.7.0.dev20250905.dist-info/METADATA,sha256=7zFs8SgMgRdkwK679QLO1W08UGscHMakHb-3NXsiEok,64100
|
652
|
+
pyg_nightly-2.7.0.dev20250905.dist-info/RECORD,,
|
torch_geometric/__init__.py
CHANGED
@@ -31,7 +31,7 @@ from .lazy_loader import LazyLoader
|
|
31
31
|
contrib = LazyLoader('contrib', globals(), 'torch_geometric.contrib')
|
32
32
|
graphgym = LazyLoader('graphgym', globals(), 'torch_geometric.graphgym')
|
33
33
|
|
34
|
-
__version__ = '2.7.0.
|
34
|
+
__version__ = '2.7.0.dev20250905'
|
35
35
|
|
36
36
|
__all__ = [
|
37
37
|
'Index',
|
@@ -21,6 +21,19 @@ class LinkPredMetricData:
|
|
21
21
|
edge_label_index: Union[Tensor, Tuple[Tensor, Tensor]]
|
22
22
|
edge_label_weight: Optional[Tensor] = None
|
23
23
|
|
24
|
+
def __post_init__(self) -> None:
|
25
|
+
# Filter all negative weights - they should not be used as ground-truth
|
26
|
+
if self.edge_label_weight is not None:
|
27
|
+
pos_mask = self.edge_label_weight > 0
|
28
|
+
self.edge_label_weight = self.edge_label_weight[pos_mask]
|
29
|
+
if isinstance(self.edge_label_index, Tensor):
|
30
|
+
self.edge_label_index = self.edge_label_index[:, pos_mask]
|
31
|
+
else:
|
32
|
+
self.edge_label_index = (
|
33
|
+
self.edge_label_index[0][pos_mask],
|
34
|
+
self.edge_label_index[1][pos_mask],
|
35
|
+
)
|
36
|
+
|
24
37
|
@property
|
25
38
|
def pred_rel_mat(self) -> Tensor:
|
26
39
|
r"""Returns a matrix indicating the relevance of the `k`-th prediction.
|
@@ -374,8 +387,6 @@ class LinkPredMetricCollection(torch.nn.ModuleDict):
|
|
374
387
|
if self.weighted and edge_label_weight is None:
|
375
388
|
raise ValueError(f"'edge_label_weight' is a required argument for "
|
376
389
|
f"weighted '{self.__class__.__name__}' metrics")
|
377
|
-
if not self.weighted:
|
378
|
-
edge_label_weight = None
|
379
390
|
|
380
391
|
data = LinkPredMetricData( # Share metric data across metrics.
|
381
392
|
pred_index_mat=pred_index_mat,
|
@@ -18,30 +18,51 @@ class SparseCrossEntropy(torch.autograd.Function):
|
|
18
18
|
) -> Tensor:
|
19
19
|
assert inputs.dim() == 2
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
# Support for both positive and negative weights:
|
22
|
+
# Positive weights scale the logits *after* softmax.
|
23
|
+
# Negative weights scale the denominator *before* softmax:
|
24
|
+
pos_y = edge_label_index
|
25
|
+
neg_y = pos_weight = neg_weight = None
|
24
26
|
|
25
|
-
out = inputs[edge_label_index[0], edge_label_index[1]]
|
26
|
-
out.neg_().add_(logsumexp[edge_label_index[0]])
|
27
27
|
if edge_label_weight is not None:
|
28
|
-
|
28
|
+
pos_mask = edge_label_weight >= 0
|
29
|
+
pos_y = edge_label_index[:, pos_mask]
|
30
|
+
pos_weight = edge_label_weight[pos_mask]
|
31
|
+
|
32
|
+
if pos_y.size(1) < edge_label_index.size(1):
|
33
|
+
neg_mask = ~pos_mask
|
34
|
+
neg_y = edge_label_index[:, neg_mask]
|
35
|
+
neg_weight = edge_label_weight[neg_mask]
|
36
|
+
|
37
|
+
if neg_y is not None and neg_weight is not None:
|
38
|
+
inputs = inputs.clone()
|
39
|
+
inputs[
|
40
|
+
neg_y[0],
|
41
|
+
neg_y[1],
|
42
|
+
] += neg_weight.abs().log().clamp(min=1e-12)
|
43
|
+
|
44
|
+
logsumexp = inputs.logsumexp(dim=-1)
|
45
|
+
ctx.save_for_backward(inputs, pos_y, pos_weight, logsumexp)
|
46
|
+
|
47
|
+
out = inputs[pos_y[0], pos_y[1]]
|
48
|
+
out.neg_().add_(logsumexp[pos_y[0]])
|
49
|
+
if pos_weight is not None:
|
50
|
+
out *= pos_weight
|
29
51
|
|
30
52
|
return out.sum() / inputs.size(0)
|
31
53
|
|
32
54
|
@staticmethod
|
33
55
|
@torch.autograd.function.once_differentiable
|
34
56
|
def backward(ctx: Any, grad_out: Tensor) -> Tuple[Tensor, None, None]:
|
35
|
-
inputs,
|
36
|
-
ctx.saved_tensors)
|
57
|
+
inputs, pos_y, pos_weight, logsumexp = ctx.saved_tensors
|
37
58
|
|
38
59
|
grad_out = grad_out / inputs.size(0)
|
39
|
-
grad_out = grad_out.expand(
|
60
|
+
grad_out = grad_out.expand(pos_y.size(1))
|
40
61
|
|
41
|
-
if
|
42
|
-
grad_out = grad_out *
|
62
|
+
if pos_weight is not None:
|
63
|
+
grad_out = grad_out * pos_weight
|
43
64
|
|
44
|
-
grad_logsumexp = scatter(grad_out,
|
65
|
+
grad_logsumexp = scatter(grad_out, pos_y[0], dim=0,
|
45
66
|
dim_size=inputs.size(0), reduce='sum')
|
46
67
|
|
47
68
|
# Gradient computation of `logsumexp`: `grad * (self - result).exp()`
|
@@ -49,7 +70,7 @@ class SparseCrossEntropy(torch.autograd.Function):
|
|
49
70
|
grad_input.exp_()
|
50
71
|
grad_input.mul_(grad_logsumexp.view(-1, 1))
|
51
72
|
|
52
|
-
grad_input[
|
73
|
+
grad_input[pos_y[0], pos_y[1]] -= grad_out
|
53
74
|
|
54
75
|
return grad_input, None, None
|
55
76
|
|
File without changes
|
{pyg_nightly-2.7.0.dev20250904.dist-info → pyg_nightly-2.7.0.dev20250905.dist-info}/licenses/LICENSE
RENAMED
File without changes
|